Skip to content

fix: return 404 for missing users - #1864

Open
krowvin wants to merge 2 commits into
developfrom
fix/users-not-found-response
Open

fix: return 404 for missing users#1864
krowvin wants to merge 2 commits into
developfrom
fix/users-not-found-response

Conversation

@krowvin

@krowvin krowvin commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • return a CDA 404 Not Found error when GET /users/{user-name} cannot find the requested user
  • document the 404 response in OpenAPI
  • add an authenticated integration test for the missing-user case
  • include the required Swagger UI screenshot

Root cause

UserDao.getByUniqueName(...) returns an empty Optional when the user does not exist. The controller converted that to null and passed it to Formats.format, whose non-null check raised the NullPointerException that CDA reported as a 500. The controller now converts the empty result to NotFoundException, allowing CDA's existing error handling to return a structured 404 response.

Verification

  • compileJava and compileTestJava
  • checkstyleMain and checkstyleTest
  • focused UserManagementTestIT.test_get_missing_user_not_found integration test
  • isolated Docker Compose end-to-end check:
    • existing user returned 200
    • missing user returned 404 with User not found: DOES_NOT_EXIST
image
  • AI tools used

Signed-off-by: Charles Graham, SWT <charles.r.graham@usace.army.mil>
@krowvin
krowvin requested a review from MikeNeilson August 5, 2026 22:06
@krowvin

krowvin commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

I found this error when fishing for a stack trace for
HydrologicEngineeringCenter/cwms-cli#247

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.

2 participants