3838
3939@unique
4040class SchemaErrorCodes (Enum ):
41+ HTTP_BAD_REQUEST = HTTPStatus .BAD_REQUEST .value
4142 HTTP_NOT_FOUND = HTTPStatus .NOT_FOUND .value
4243 HTTP_CONFLICT = HTTPStatus .CONFLICT .value
4344 HTTP_UNPROCESSABLE_ENTITY = HTTPStatus .UNPROCESSABLE_ENTITY .value
@@ -835,11 +836,11 @@ def _validate_schema_request_body(self, content_type: str, body: Union[dict, Any
835836 if not isinstance (body , dict ):
836837 self .r (
837838 body = {
838- "error_code" : SchemaErrorCodes .HTTP_INTERNAL_SERVER_ERROR .value ,
839- "message" : "Internal Server Error " ,
839+ "error_code" : SchemaErrorCodes .HTTP_BAD_REQUEST .value ,
840+ "message" : "Malformed request " ,
840841 },
841842 content_type = content_type ,
842- status = HTTPStatus .INTERNAL_SERVER_ERROR ,
843+ status = HTTPStatus .BAD_REQUEST ,
843844 )
844845 for attr in body :
845846 if attr not in {"schema" , "schemaType" }:
@@ -853,6 +854,15 @@ def _validate_schema_request_body(self, content_type: str, body: Union[dict, Any
853854 )
854855
855856 def _validate_schema_type (self , content_type : str , data : JsonData ) -> SchemaType :
857+ if not isinstance (data , dict ):
858+ self .r (
859+ body = {
860+ "error_code" : SchemaErrorCodes .HTTP_BAD_REQUEST .value ,
861+ "message" : "Malformed request" ,
862+ },
863+ content_type = content_type ,
864+ status = HTTPStatus .BAD_REQUEST ,
865+ )
856866 schema_type_unparsed = data .get ("schemaType" , SchemaType .AVRO .value )
857867 try :
858868 schema_type = SchemaType (schema_type_unparsed )
0 commit comments