Skip to content

fix(profile): specific, privacy-safe errors for duplicate-email and wrong-password on profile update - #931

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/profile-update-error-messages
Jun 3, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/profile-update-error-messages

Conversation

@cristim

@cristim cristim commented Jun 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Wrong current password on profile update now returns HTTP 401 with "Current password is incorrect" instead of a generic 500
  • Duplicate email on profile update now returns HTTP 409 with "Unable to update email" -- privacy-safe, does not confirm another account's existence (prevents enumeration)
  • New ErrCurrentPasswordIncorrect sentinel added; updateUserEmail fixed to return ErrEmailInUse sentinel instead of a plain string
  • New mapProfileUpdateError handler maps both sentinels to the correct status code and message
  • Handler tests added for both error paths; service-layer tests assert errors.Is on both sentinels

Closes #929

Test plan

  • go test ./internal/auth/... -- TestService_UpdateUserProfile subtests "wrong current password" and "duplicate email returns ErrEmailInUse sentinel" pass
  • go test ./internal/api/... -- TestHandler_updateProfile_WrongCurrentPassword (expects 401) and TestHandler_updateProfile_DuplicateEmail (expects 409 with "Unable to update email") pass
  • go build ./... succeeds
  • Full suite go test ./internal/... -- all 4283 tests pass
  • Manual: profile update with wrong current password surfaces "Current password is incorrect" in UI toast instead of "Internal server error"
  • Manual: profile update with a taken email address surfaces "Unable to update email" in UI -- does NOT say "already in use"

… email

On the profile-update path, wrong current password and duplicate email
both fell through to the generic 500 "Internal server error" because
UpdateUserProfile returned plain fmt.Errorf strings that the handler
did not recognise as client errors.

- Add ErrCurrentPasswordIncorrect sentinel to internal/auth/errors.go.
- Return the sentinel (not a plain string) from UpdateUserProfile when
  the current password does not match.
- Return the existing ErrEmailInUse sentinel (not a plain string) from
  updateUserEmail when the address is taken.
- Add mapProfileUpdateError in handler_auth.go: wrong password -> 401
  with the sentinel message; duplicate email -> 409 with the neutral
  privacy-safe message "Unable to update email" (does not confirm
  another account's existence, preventing enumeration).
- Add handler tests for both new error paths asserting the correct
  status code and message.
- Add service-layer tests asserting errors.Is on both sentinels so the
  contract is positively enforced.

Closes #929
@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/this-sprint Within the current sprint impact/all-users Affects every user effort/s Hours type/bug Defect labels Jun 3, 2026
@coderabbitai

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 31 minutes and 24 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 94a84d85-04fe-43e7-a8c0-30ad9b20b2c1

📥 Commits

Reviewing files that changed from the base of the PR and between 56a7797 and 2cfae43.

📒 Files selected for processing (5)
  • internal/api/handler_auth.go
  • internal/api/handler_auth_test.go
  • internal/auth/errors.go
  • internal/auth/service_user.go
  • internal/auth/service_user_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/profile-update-error-messages

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim

cristim commented Jun 3, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim merged commit f3920e4 into feat/multicloud-web-frontend Jun 3, 2026
4 checks passed
@cristim
cristim deleted the fix/profile-update-error-messages branch June 3, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/all-users Affects every user priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant