Skip to content
This repository was archived by the owner on Jun 7, 2025. It is now read-only.

Commit 3f0d014

Browse files
committed
🐛 fix: update user update method to exclude None values and improve error handling for no changes provided
1 parent 5fa322c commit 3f0d014

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

app/repositories/user_repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def update_user(self, user_id: EmailStr, user_data: schemas.UserUpdate):
106106
if not user_current_data:
107107
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="User not found")
108108

109-
provided_data = user_data.model_dump(exclude_unset=True)
109+
provided_data = user_data.model_dump(exclude_unset=True, exclude_none=True)
110110
if not provided_data:
111111
raise HTTPException(
112112
status_code=status.HTTP_400_BAD_REQUEST,

tests/repositories/test_user_repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ async def test__unit_test__update_user_error(user_repository, mock_database):
231231

232232
@pytest.mark.asyncio
233233
async def test__unit_test__update_user_no_changes_provide(user_repository, mock_database):
234-
update_data = UserUpdate()
234+
update_data = UserUpdate(_id=None)
235235
with pytest.raises(HTTPException) as exc_info:
236236
await user_repository.update_user("user@test.com", update_data)
237237
assert exc_info.value.status_code == 400

0 commit comments

Comments
 (0)