diff --git a/app/error_handling.py b/app/error_handling.py index b06fa48..5e6fd95 100644 --- a/app/error_handling.py +++ b/app/error_handling.py @@ -3,9 +3,9 @@ BOOL_ERROR_MESSAGE = "ValueError: boolean values expected [True,False,1,0]. rage_inducing | action_packed | skill_based | mature_themes | open_world | multiplayer" def raise_request_error(message): - """Raises HTTPError with code 422 for bad input with a custom message.""" - raise HTTPException(status_code=422, detail=message) + """Raises HTTPError with code 400 for bad input with a custom message.""" + raise HTTPException(status_code=400, detail=message) def raise_boolean_error(): - """Raises HTTPError with code 422 for when input values aren't booleans.""" - raise HTTPException(status_code=422, detail=BOOL_ERROR_MESSAGE) \ No newline at end of file + """Raises HTTPError with code 400 for when input values aren't booleans.""" + raise HTTPException(status_code=400, detail=BOOL_ERROR_MESSAGE) \ No newline at end of file diff --git a/main.py b/main.py index e6ab545..dacfa75 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ from app import input_parser as parser from app.database import get_db -VERSION = "1.1.1" +VERSION = "1.1.2" # Prometheus metrics REQUEST_COUNT = Counter("http_requests_total", "Total HTTP requests", ["method", "endpoint", "status"]) REQUEST_LATENCY = Summary("http_request_latency_seconds", "Request latency in seconds") diff --git a/test/test_error_handling.py b/test/test_error_handling.py index 671afd9..b75233f 100644 --- a/test/test_error_handling.py +++ b/test/test_error_handling.py @@ -6,10 +6,10 @@ class TestRequestErrorHandling(unittest.TestCase): def test_request_error_handling(self): with self.assertRaises(HTTPException) as _: error.raise_request_error("") - self.assertEqual(_.exception.status_code,422,msg = "Wrong status code was given") + self.assertEqual(_.exception.status_code,400,msg = "Wrong status code was given") class TestBooleanErrorHandling(unittest.TestCase): def test_boolean_error_handling(self): with self.assertRaises(HTTPException) as _: error.raise_boolean_error() - self.assertEqual(_.exception.status_code,422,msg = "Wrong status code was given") + self.assertEqual(_.exception.status_code,400,msg = "Wrong status code was given") diff --git a/test/test_input_parser.py b/test/test_input_parser.py index f454d69..5a191f3 100644 --- a/test/test_input_parser.py +++ b/test/test_input_parser.py @@ -32,4 +32,4 @@ def test_parse_input(self): def test_wrong_input(self): with self.assertRaises(HTTPException) as _: TestClass = parser.parse_input([1,"a",False,{"Name":"Test"}]) - self.assertEqual(_.exception.status_code,422,msg = "Incorrect or no error raised with wrong datatypes") \ No newline at end of file + self.assertEqual(_.exception.status_code,400,msg = "Incorrect or no error raised with wrong datatypes") \ No newline at end of file