docs: update Link endpoint — 404 for user-not-found, 409 for already-linked#248
Merged
Merged
Conversation
… for already-linked The OIDC/OAuth2 Link endpoint previously returned 409 Conflict for both "account already linked" and "user not found" conditions. PR #231 fixed the handler to return 404 Not Found when Users.FindByID returns ErrNotFound, reserving 409 Conflict solely for the already-linked case. Update HTTP status code tables in docs/handler/oidc.md and docs/handler/oauth2.md to reflect this distinction. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the handler documentation to reflect the corrected semantics of the OIDC/OAuth2 Link endpoints: returning 404 Not Found when the linking user no longer exists, while reserving 409 Conflict for the “already linked” case (aligning docs with PR #231 behavior).
Changes:
- Update
OIDCHandlerdocs to split the previous combined 409 case into distinct 404 (user missing) and 409 (already linked) entries. - Update
OAuth2Handlerdocs similarly (with one wording inconsistency noted in a review comment).
Show a summary per file
| File | Description |
|---|---|
| docs/handler/oidc.md | Splits Link status table entries to document 404 (user missing) vs 409 (already linked). |
| docs/handler/oauth2.md | Splits Link status table entries to document 404 (user missing) vs 409 (already linked); 409 wording needs alignment with actual behavior. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
… and oidc docs The OIDCSubject field is shared between OIDC and OAuth2 handlers, so a 409 fires regardless of which provider the user previously linked via. Using "external identity" avoids implying provider specificity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR #231 fixed the OIDC and OAuth2
Linkendpoint to return404 Not FoundwhenUsers.FindByIDreturnsErrNotFound, instead of conflating it with409 Conflict(reserved for the "account already linked" case).This PR updates the HTTP status code reference tables in the handler documentation to accurately reflect that distinction.
Changes
docs/handler/oidc.md— split theLink | 409 Conflictrow into:Link | 404 Not Found— user not found (ErrNotFoundfromUsers.FindByID)Link | 409 Conflict— account already linked to an OIDC identitydocs/handler/oauth2.md— same split forOAuth2HandlerMotivation
Before this fix, clients following the API reference would incorrectly expect
409when a user account had been deleted between nonce issuance and link initiation. The404response is semantically correct and more actionable for API consumers.Testing
Documentation-only change; no functional code modified.
Greptile Summary
This PR updates the HTTP status code reference tables in
docs/handler/oidc.mdanddocs/handler/oauth2.mdto reflect the fix from PR #231, which made theLinkendpoint return404 Not FoundwhenUsers.FindByIDreturnsErrNotFoundinstead of conflating it with409 Conflict.oidc.md— splits the old combinedLink | 409row into a404row (user not found) and a409row (account already linked); the existing500description already covers the DB-error case.oauth2.md— same split; however, the500description forLinkomits the "DB error when looking up user by ID" case that exists in the handler code and is documented inoidc.md.Confidence Score: 5/5
Documentation-only change; no functional code modified, safe to merge.
Both doc files correctly split the old combined row into the accurate 404 and 409 responses, matching the handler implementations. The one gap — the missing DB-error note in oauth2.md's 500 row — is a minor doc omission with no impact on the running service.
docs/handler/oauth2.md — the Link 500 description is slightly less complete than its oidc.md counterpart.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Link handler called] --> B{LinkNonces nil?} B -- Yes --> C[503 Service Unavailable] B -- No --> D{Nonce in query?} D -- No --> E[400 Bad Request] D -- Yes --> F[consumeLinkNonce] F --> G{Error?} G -- ErrNotFound --> H[401 Unauthorized] G -- Other error --> I[500 Internal Server Error] G -- nil --> J[Users.FindByID] J --> K{Error?} K -- ErrNotFound --> L[404 Not Found] K -- Other error --> M[500 Internal Server Error] K -- nil --> N{OIDCSubject != nil?} N -- Yes --> O[409 Conflict] N -- No --> P[302 Found — redirect to provider]Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "docs: use "external identity" for 409 Li..." | Re-trigger Greptile