Skip to content

fix(api): return 404 when changing the role of a missing user - #699

Merged
ValgulNecron merged 1 commit into
masterfrom
claude/013-user-role-404
Oct 14, 2026
Merged

ValgulNecron merged 1 commit into
masterfrom
claude/013-user-role-404

Conversation

@ValgulNecron

@ValgulNecron ValgulNecron commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Before: PATCH /users/{id} with a role on a user that no longer exists returned 500 "internal error". The role UPDATE touched 0 rows and the handler passed sql.ErrNoRows to httperr.Write, which does not map it, so it fell through to 500.

After: the same request returns 404 "user not found", matching what the endpoint already returns for a missing user on the non-role path.

How: api/internal/handlers/users.go writes http.Error(w, "user not found", http.StatusNotFound) when RowsAffected is 0. Test change (valgul signed off on the spec 013 card, 2026-10-14): the subtest in api/internal/handlers/users_branches_test.go that pinned the 500 is renamed to "role update on a missing user is 404 (RowsAffected path)" and now asserts 404. Found while writing the spec 013 T040 live spec; once this merges, T040's error path asserts this 404.

🤖 Generated with Claude Code


Generated by Claude Code

PATCH /users/{id} with a role on a deleted user passed sql.ErrNoRows to httperr, which maps it to 500. Return 404 user not found, like the non-role path does. The branch test that pinned the 500 now expects 404.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
@ValgulNecron ValgulNecron added area: api REST/WebSocket gateway type: fix Bug fix labels Oct 14, 2026 — with Claude
@ValgulNecron ValgulNecron self-assigned this Oct 14, 2026
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 21 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: GameplanePanel/Gameplane/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a34f1d74-694d-44a4-9213-5205cf295f0d
📥 Commits

Reviewing files that changed from the base of the PR and between ec0f332 and 91e30ce.

📒 Files selected for processing: 2
  • api/internal/handlers/users.go
  • api/internal/handlers/users_branches_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

Copy link
Copy Markdown

CI Report - 91e30ce

run 38640149328 - attempt 1

0 failed - 22 passed - 10 skipped - 48m17s elapsed

Coverage

no coverage/* commit statuses found on 91e30ce

Changed

Area Files +/-
api/ 2 +4/-4

Slowest jobs

Job Duration
e2e telemetry / amd64 (kind) 22m41s
e2e telemetry / arm64 (kind) 22m23s
build e2e images 13m38s
build e2e images (arm64) 10m11s
e2e multicluster / arm64 (kind x2) 8m15s

e2e buckets run

api-agent, api-auth, api-mods, api-rbac, api-roles, bot-fast, multicluster, operator, ratelimit, telemetry, upgrade

@ValgulNecron
ValgulNecron marked this pull request as ready for review October 14, 2026 22:16
@ValgulNecron
ValgulNecron merged commit 869ea6b into master Oct 14, 2026
53 checks passed
ValgulNecron pushed a commit that referenced this pull request Oct 14, 2026
With #699 merged, changing a deleted user's role returns 404 "user not
found". The error path now changes the role in the Edit dialog and asserts
the inline alert, as T040 specifies, instead of using the namespace-grant
404. Tick T040.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
ValgulNecron pushed a commit that referenced this pull request Oct 15, 2026
G-08 closes on live run 38649266488, where the users spec asserts the
role-change 404 from #699. T044 is done: typecheck:e2e passes and the
login count and duration are recorded. Summary recounted to 15/24 closed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: api REST/WebSocket gateway type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants