Skip to content

Commit cbfa186

Browse files
committed
Show raw returned value in case JSON decoding fails
1 parent 2167a91 commit cbfa186

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

kafka_schema_registry/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from kafka.admin import NewTopic
1111
from kafka.errors import TopicAlreadyExistsError, NoBrokersAvailable
1212
from requests import request
13+
from request.exceptions import JSONDecodeError
1314

1415
logger = logging.getLogger(__name__)
1516

@@ -86,9 +87,14 @@ def publish_schemas(
8687
'Content-Type': 'application/json'
8788
}
8889
)
89-
if 'id' not in value_resp.json():
90+
try:
91+
obj = value_resp.json()
92+
except json.JSONDecodeError:
93+
logger.error(f'Error decoding response: {value_resp.text}')
94+
raise
95+
if 'id' not in obj:
9096
logger.error(f'No id in response: {value_resp.json()}')
91-
value_schema_id = value_resp.json()['id']
97+
value_schema_id = obj['id']
9298

9399
key_schema_id = None
94100
if key_schema is not None:

requirements-dev.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
pytest==6.2.5
2-
pytest-cov==3.0.0
3-
flake8==4.0.1
4-
responses==0.17.0
5-
twine==3.7.1
6-
wheel==0.37.1
1+
pytest==8.3.4
2+
pytest-cov==6.0.0
3+
flake8==7.1.1
4+
responses==0.25.3
5+
twine==6.0.1
6+
wheel==0.45.1
77

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
fastavro==1.4.9
1+
fastavro==1.9.7
22
kafka-python==2.0.2
3-
requests==2.27.1
3+
requests==2.32.3

0 commit comments

Comments
 (0)