Skip to content

Return 400 for nonexistent user roles without partial grants - #1936

Open
krowvin wants to merge 2 commits into
developfrom
fix/1933-missing-user-role
Open

Return 400 for nonexistent user roles without partial grants#1936
krowvin wants to merge 2 commits into
developfrom
fix/1933-missing-user-role

Conversation

@krowvin

@krowvin krowvin commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Return HTTP 400 with the missing role names and requested office when assigning roles that do not exist.
  • Validate every role before granting any, so a mixed valid/invalid request cannot partially change permissions. Preserve case-insensitive role matching.
  • Document the response and cover missing roles, office-specific roles, API-key authentication, and unchanged permissions after rejection.

Closes #1933

Validation

Local Java 11 gradlew build passed, including 782 service unit tests (zero failures, 40 skipped), Oracle-backed OpenAPI conversion, and generated TypeScript client checks. All 17 Oracle-backed UserManagementTestIT cases passed, including session and API-key authentication, office-specific roles, case-insensitive valid roles, and unchanged permissions after rejection.

Tested the same request against baseline and fixed local WARs with an authenticated user administrator: baseline returned 500 Database Error; fixed returned 400 Bad Request. with details.message listing both missing roles.

curl -X POST 'http://localhost:8384/cwms-data/user/m5hectest/roles/SWT' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  --data-binary '["MISSING ROLE ONE","MISSING ROLE TWO"]'

The baseline used port 8383. m5hectest is the bundled synthetic local test account; $TOKEN is its local administrator token.

  • AI tools used

Signed-off-by: Charles Graham, SWT <charles.r.graham@usace.army.mil>
@krowvin
krowvin requested a review from MikeNeilson September 10, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Missing Role throws a 500

1 participant