diff --git a/kafka_schema_registry/__init__.py b/kafka_schema_registry/__init__.py index bae3f41..60f4b37 100644 --- a/kafka_schema_registry/__init__.py +++ b/kafka_schema_registry/__init__.py @@ -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__) @@ -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: diff --git a/requirements-dev.txt b/requirements-dev.txt index 0d7066b..9923f15 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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 diff --git a/requirements.txt b/requirements.txt index 21c60b8..42ea387 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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