Skip to content

Commit 4d19c3f

Browse files
committed
feat(schema): provide a way set _ignore_default_error to True (default to false)
_ignore_default_error will ignore errors like: "Default value <null> must match first schema in union with type: null" ...which I agree are errors but are painful to fix when backporting stuff.
1 parent 76bb939 commit 4d19c3f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

schema_registry/client/schema.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class AvroSchema(BaseSchema):
6969
def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
7070
self._expanded_schema: typing.Optional[typing.Dict] = None
7171
self._flat_schema: typing.Optional[typing.Dict] = None
72+
self._ignore_default_error: typing.Optional[bool] = False
7273

7374
super().__init__(*args, **kwargs)
7475

@@ -103,14 +104,14 @@ def flat_schema(self) -> typing.Dict:
103104
# NOTE: Dict expected when we pass a dict
104105
self._flat_schema = typing.cast(
105106
typing.Dict,
106-
fastavro.parse_schema(self.raw_schema, _write_hint=False, _force=True),
107+
fastavro.parse_schema(self.raw_schema, _write_hint=False, _force=True, _ignore_default_error=self._ignore_default_error),
107108
)
108109

109110
return self._flat_schema
110111

111112
def parse_schema(self, schema: typing.Dict) -> typing.Dict:
112113
# NOTE: Dict expected when we pass a dict
113-
return typing.cast(typing.Dict, fastavro.parse_schema(schema, _force=True))
114+
return typing.cast(typing.Dict, fastavro.parse_schema(schema, _force=True, _ignore_default_error=True))
114115

115116
@staticmethod
116117
def load(fp: str) -> AvroSchema:

0 commit comments

Comments
 (0)