diff --git a/karapace/schema_reader.py b/karapace/schema_reader.py index 40a05d8fa..27e7095f2 100644 --- a/karapace/schema_reader.py +++ b/karapace/schema_reader.py @@ -500,9 +500,9 @@ def _handle_msg_schema(self, key: dict, value: dict | None) -> None: try: schema_type_parsed = SchemaType(schema_type) - except ValueError: + except ValueError as e: LOG.warning("Invalid schema type: %s", schema_type) - return + raise e # This does two jobs: # - Validates the schema's JSON @@ -519,18 +519,18 @@ def _handle_msg_schema(self, key: dict, value: dict | None) -> None: candidate_references = [reference_from_mapping(reference_data) for reference_data in schema_references] resolved_references, resolved_dependencies = self.resolve_references(candidate_references) schema_str = json.dumps(json.loads(schema_str), sort_keys=True) - except json.JSONDecodeError: + except json.JSONDecodeError as e: LOG.warning("Schema is not valid JSON") - return - except InvalidReferences: + raise e + except InvalidReferences as e: LOG.exception("Invalid AVRO references") - return + raise e elif schema_type_parsed == SchemaType.JSONSCHEMA: try: schema_str = json.dumps(json.loads(schema_str), sort_keys=True) - except json.JSONDecodeError: + except json.JSONDecodeError as e: LOG.warning("Schema is not valid JSON") - return + raise e elif schema_type_parsed == SchemaType.PROTOBUF: try: if schema_references: @@ -544,12 +544,12 @@ def _handle_msg_schema(self, key: dict, value: dict | None) -> None: normalize=False, ) schema_str = str(parsed_schema) - except InvalidSchema: + except InvalidSchema as e: LOG.exception("Schema is not valid ProtoBuf definition") - return - except InvalidReferences: + raise e + except InvalidReferences as e: LOG.exception("Invalid Protobuf references") - return + raise e try: typed_schema = TypedSchema( @@ -559,8 +559,8 @@ def _handle_msg_schema(self, key: dict, value: dict | None) -> None: dependencies=resolved_dependencies, schema=parsed_schema, ) - except (InvalidSchema, JSONDecodeError): - return + except (InvalidSchema, JSONDecodeError) as e: + raise e self.database.insert_schema_version( subject=schema_subject,