From ecfe0603419314f5e890dbea2de9d6f898463e02 Mon Sep 17 00:00:00 2001 From: Andrew Weiland Date: Mon, 27 Jul 2026 09:14:28 -0400 Subject: [PATCH] Changed deprecated status code from 422_UNPROCESSABLE_ENTITY to 422_UNPROCESSABLE_CONTENT --- src/apps/shared/domain/response/errors.py | 2 +- src/apps/shared/exception.py | 2 +- src/apps/users/tests/test_mfa.py | 2 +- src/apps/users/tests/test_mfa_disable_confirm.py | 2 +- src/apps/users/tests/test_mfa_disable_security.py | 2 +- src/apps/users/tests/test_mfa_disable_verify.py | 2 +- src/apps/users/tests/test_mfa_recovery_codes_view.py | 2 +- src/apps/users/tests/test_user.py | 2 +- src/infrastructure/http/exceptions.py | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/apps/shared/domain/response/errors.py b/src/apps/shared/domain/response/errors.py index 5477fecd845..7841703571a 100644 --- a/src/apps/shared/domain/response/errors.py +++ b/src/apps/shared/domain/response/errors.py @@ -59,5 +59,5 @@ class ErrorResponseMulti(PublicModel): DEFAULT_OPENAPI_RESPONSE: ResponseType = { # status.HTTP_500_INTERNAL_SERVER_ERROR: __DEFAULT_ERROR_RESPONSE, status.HTTP_400_BAD_REQUEST: __DEFAULT_ERROR_RESPONSE, - status.HTTP_422_UNPROCESSABLE_ENTITY: __DEFAULT_ERROR_RESPONSE, + status.HTTP_422_UNPROCESSABLE_CONTENT: __DEFAULT_ERROR_RESPONSE, } diff --git a/src/apps/shared/exception.py b/src/apps/shared/exception.py index 1bc55c3fa82..66f08690c3d 100644 --- a/src/apps/shared/exception.py +++ b/src/apps/shared/exception.py @@ -66,7 +66,7 @@ class NotFoundError(BaseError): class FieldError(BaseError): message = _("Invalid value.") - status_code = status.HTTP_422_UNPROCESSABLE_ENTITY + status_code = status.HTTP_422_UNPROCESSABLE_CONTENT type = ExceptionTypes.INVALID_VALUE zero_path: str | None = "body" diff --git a/src/apps/users/tests/test_mfa.py b/src/apps/users/tests/test_mfa.py index b686bcd2833..f0bce57170b 100644 --- a/src/apps/users/tests/test_mfa.py +++ b/src/apps/users/tests/test_mfa.py @@ -201,7 +201,7 @@ async def test_mfa_totp_verify_invalid_code_format(self, client: TestClient, use data={"code": "12345"}, # Only 5 digits ) - assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY + assert response.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT async def test_mfa_status_in_user_retrieve(self, client: TestClient, user: User, session: AsyncSession): """Test that /users/me returns mfaEnabled status.""" diff --git a/src/apps/users/tests/test_mfa_disable_confirm.py b/src/apps/users/tests/test_mfa_disable_confirm.py index fe91f8cc1fa..3563fe96743 100644 --- a/src/apps/users/tests/test_mfa_disable_confirm.py +++ b/src/apps/users/tests/test_mfa_disable_confirm.py @@ -104,7 +104,7 @@ async def test_confirm_without_token_fails(self, client: TestClient, user_with_m # Try to confirm without token response = await client.post(self.disable_confirm_url, data={}) - assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY + assert response.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT async def test_confirm_with_invalid_token_fails(self, client: TestClient, user_with_mfa: User): """Confirmation with invalid token returns error.""" diff --git a/src/apps/users/tests/test_mfa_disable_security.py b/src/apps/users/tests/test_mfa_disable_security.py index 3cb6ef747c0..e5e95828d0b 100644 --- a/src/apps/users/tests/test_mfa_disable_security.py +++ b/src/apps/users/tests/test_mfa_disable_security.py @@ -354,7 +354,7 @@ async def test_sql_injection_in_totp_code(self, client: TestClient, user_with_mf # Should fail safely (validation error or invalid code) assert response.status_code in ( status.HTTP_400_BAD_REQUEST, - status.HTTP_422_UNPROCESSABLE_ENTITY, + status.HTTP_422_UNPROCESSABLE_CONTENT, ) async def test_xss_in_response_messages(self, client: TestClient, user_with_mfa: User): diff --git a/src/apps/users/tests/test_mfa_disable_verify.py b/src/apps/users/tests/test_mfa_disable_verify.py index 062a7fd20cd..89d7c5e7fdd 100644 --- a/src/apps/users/tests/test_mfa_disable_verify.py +++ b/src/apps/users/tests/test_mfa_disable_verify.py @@ -116,7 +116,7 @@ async def test_disable_verify_without_mfa_token_fails(self, client: TestClient, verify_data = {"code": "123456"} response = await client.post(self.disable_verify_url, data=verify_data) - assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY + assert response.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT async def test_disable_verify_with_valid_recovery_code_emits_recovery_use_audit( self, client: TestClient, user_with_mfa: User, session: AsyncSession, mocker: MockerFixture diff --git a/src/apps/users/tests/test_mfa_recovery_codes_view.py b/src/apps/users/tests/test_mfa_recovery_codes_view.py index fb775c64f6d..62221257869 100644 --- a/src/apps/users/tests/test_mfa_recovery_codes_view.py +++ b/src/apps/users/tests/test_mfa_recovery_codes_view.py @@ -397,7 +397,7 @@ async def test_download_without_token_fails(self, client: TestClient, user: User resp = await client.get(self.recovery_codes_download_url) # Assertions - Should fail due to missing required parameter - assert resp.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY + assert resp.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT async def test_download_with_invalid_token_fails(self, client: TestClient, user: User, session: AsyncSession): """Test that download fails with invalid download_token.""" diff --git a/src/apps/users/tests/test_user.py b/src/apps/users/tests/test_user.py index 7c71556fd95..d3230bf7e75 100644 --- a/src/apps/users/tests/test_user.py +++ b/src/apps/users/tests/test_user.py @@ -116,7 +116,7 @@ async def test_create_user_not_valid_email(self, client: TestClient, request_dat data = request_data.model_dump() data["email"] = "tom2@gettingcurious@com" response = await client.post(self.user_create_url, data=data) - assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY + assert response.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT result = response.json()["result"] assert len(result) == 1 assert ( diff --git a/src/infrastructure/http/exceptions.py b/src/infrastructure/http/exceptions.py index 91bfa23283e..7c1a8cdf2ac 100644 --- a/src/infrastructure/http/exceptions.py +++ b/src/infrastructure/http/exceptions.py @@ -109,7 +109,7 @@ def pydantic_validation_errors_handler(request: Request, error: RequestValidatio response = ErrorResponseMulti(result=errors) return JSONResponse( content=jsonable_encoder(response.model_dump(by_alias=True)), - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + status_code=status.HTTP_422_UNPROCESSABLE_CONTENT, )