Skip to content

Commit

Permalink
Show raw returned value in case JSON decoding fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopofar committed Dec 9, 2024
1 parent 2167a91 commit cbfa186
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 8 additions & 2 deletions kafka_schema_registry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from kafka.admin import NewTopic
from kafka.errors import TopicAlreadyExistsError, NoBrokersAvailable
from requests import request
from request.exceptions import JSONDecodeError

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -86,9 +87,14 @@ def publish_schemas(
'Content-Type': 'application/json'
}
)
if 'id' not in value_resp.json():
try:
obj = value_resp.json()
except json.JSONDecodeError:
logger.error(f'Error decoding response: {value_resp.text}')
raise
if 'id' not in obj:
logger.error(f'No id in response: {value_resp.json()}')
value_schema_id = value_resp.json()['id']
value_schema_id = obj['id']

key_schema_id = None
if key_schema is not None:
Expand Down
12 changes: 6 additions & 6 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pytest==6.2.5
pytest-cov==3.0.0
flake8==4.0.1
responses==0.17.0
twine==3.7.1
wheel==0.37.1
pytest==8.3.4
pytest-cov==6.0.0
flake8==7.1.1
responses==0.25.3
twine==6.0.1
wheel==0.45.1

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fastavro==1.4.9
fastavro==1.9.7
kafka-python==2.0.2
requests==2.27.1
requests==2.32.3

0 comments on commit cbfa186

Please sign in to comment.