-
Notifications
You must be signed in to change notification settings - Fork 919
Closed
Labels
bugReporting an unexpected or problematic behavior of the codebaseReporting an unexpected or problematic behavior of the codebase
Description
Description
Since version 1.9.0 of avro-python3 Schema.props returns a MappingProxyType
object which not json-serializable by default and leads to following exceptions:
...
File "<venv>/lib/python3.7/site-packages/confluent_kafka/avro/__init__.py", line 80, in produce
value = self._serializer.encode_record_with_schema(topic, value_schema, value)
File "<venv>/lib/python3.7/site-packages/confluent_kafka/avro/serializer/message_serializer.py", line 105, in encode_record_with_schema
schema_id = self.registry_client.register(subject, schema)
File "<venv>/lib/python3.7/site-packages/confluent_kafka/avro/cached_schema_registry_client.py", line 214, in register
body = {'schema': json.dumps(avro_schema.to_json())}
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type mappingproxy is not JSON serializable
To fix this, the registry client (and everything else) should use Schema.__str__
to get the json representation instead of calling json.dumps(avro_schema.to_json())
saabeilin, mpyatishev, ftobia, justinturpin, rgabo and 22 more
Metadata
Metadata
Assignees
Labels
bugReporting an unexpected or problematic behavior of the codebaseReporting an unexpected or problematic behavior of the codebase