diff --git a/karapace/schema_registry_apis.py b/karapace/schema_registry_apis.py index f3377d567..662820a81 100644 --- a/karapace/schema_registry_apis.py +++ b/karapace/schema_registry_apis.py @@ -1104,14 +1104,14 @@ async def subjects_schema_post( schema_type=schema_type, schema_str=schema_str, references=references, dependencies=new_schema_dependencies ) except InvalidSchema: - self.log.exception("No proper parser found") + self.log.warning("Invalid schema: %r", schema_str, exc_info=True) self.r( body={ - "error_code": SchemaErrorCodes.HTTP_INTERNAL_SERVER_ERROR.value, + "error_code": SchemaErrorCodes.INVALID_SCHEMA.value, "message": f"Error while looking up schema under subject {subject}", }, content_type=content_type, - status=HTTPStatus.INTERNAL_SERVER_ERROR, + status=HTTPStatus.UNPROCESSABLE_ENTITY, ) except InvalidReferences: human_error = "Provided references is not valid" diff --git a/tests/integration/test_schema.py b/tests/integration/test_schema.py index 90d4172bd..84c1a570c 100644 --- a/tests/integration/test_schema.py +++ b/tests/integration/test_schema.py @@ -1461,7 +1461,7 @@ async def test_schema_subject_post_invalid(registry_async_client: Client) -> Non f"subjects/{subject_1}", json={"schema": json.dumps({"type": "invalid_type"})}, ) - assert res.status_code == 500, "Invalid schema for existing subject should return 500" + assert res.status_code == 422, "Invalid schema for existing subject should return 500" assert res.json()["message"] == f"Error while looking up schema under subject {subject_1}" # Subject is not found