Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
| data = update.model_dump(exclude_unset=True) | ||
| if "username" in data: | ||
| existing = await crud_user.get_user_by_username(db, data["username"]) | ||
| if existing and existing.id != current_user.id: | ||
| raise HTTPException( | ||
| status_code=status.HTTP_400_BAD_REQUEST, detail="Username already taken" | ||
| ) | ||
| if "email" in data: | ||
| existing = await crud_user.get_user_by_email(db, data["email"]) | ||
| if existing and existing.id != current_user.id: | ||
| raise HTTPException( | ||
| status_code=status.HTTP_400_BAD_REQUEST, detail="Email already taken" |
There was a problem hiding this comment.
[P1] Skip email uniqueness check when clearing address
Both update_me and patch_me run a uniqueness check whenever the payload contains an email key, even when the value is null. Because get_user_by_email is then called with None, the query matches the first user that already has a NULL email (which is common because signups default to no email). The existing.id != current_user.id branch fires and returns 400 "Email already taken", making it impossible for a user to remove their email address while any other user also lacks one. The check should only run when a non-NULL email is supplied.
Useful? React with 👍 / 👎.
Summary
Testing
python3 -m pytesthttps://chatgpt.com/codex/tasks/task_e_68b10740b9508329b82d205529f92a63