Skip to content

Comments

fix(exception-handling): Add ResourceNotFoundException handler for structured error responses [MDD-78]#369

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1771873158-mdd78-resource-not-found-handler
Open

fix(exception-handling): Add ResourceNotFoundException handler for structured error responses [MDD-78]#369
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1771873158-mdd78-resource-not-found-handler

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Feb 23, 2026

fix(exception-handling): Add ResourceNotFoundException handler [MDD-78]

Summary

Adds explicit @ExceptionHandler for ResourceNotFoundException in both REST and GraphQL exception handlers so that endpoints return structured JSON error responses ({"message": "Resource not found"}) instead of raw/unstructured 404s. This affects all endpoints that throw ResourceNotFoundException (ProfileApi, ArticleApi, CommentsApi, etc.).

Changes:

  • CustomizeExceptionHandler: New handler returning 404 with {"message": "Resource not found"}
  • GraphQLCustomizeExceptionHandler: New else if branch returning NOT_FOUND typed GraphQL error
  • ProfileApiTest: 3 new tests for follow/unfollow/get-profile with nonexistent users, plus CustomizeExceptionHandler added to test @Import

Review & Testing Checklist for Human

  • Verify @ResponseStatus vs @ExceptionHandler precedence: ResourceNotFoundException has @ResponseStatus(HttpStatus.NOT_FOUND) on the class. Confirm that the new @ExceptionHandler takes precedence in all cases (it should, but this is the highest-risk interaction). Consider whether the @ResponseStatus annotation should be removed now that there's an explicit handler.
  • Confirm no regression on other endpoints: The new handler catches all ResourceNotFoundException usages app-wide (ArticleApi, CommentsApi, ArticleFavoriteApi, GraphQL datafetchers). Verify these endpoints still return 404 as expected with the new structured body.
  • GraphQL path is untested: No GraphQL-specific test was added for ResourceNotFoundException. Consider whether a test in the GraphQL layer is needed for confidence.

Suggested manual test plan:

  1. Start the app locally
  2. POST /profiles/nonexistent-user/follow with auth → expect 404 with {"message": "Resource not found"}
  3. DELETE /profiles/nonexistent-user/follow with auth → same
  4. GET /profiles/nonexistent-user → same
  5. Try a nonexistent article endpoint (e.g. GET /articles/nonexistent-slug) to verify the handler works app-wide

Notes


Open with Devin

Add explicit exception handlers for ResourceNotFoundException in both
REST and GraphQL exception handlers to return structured error messages
instead of raw 404 responses.

- CustomizeExceptionHandler: returns {"message": "Resource not found"} with 404
- GraphQLCustomizeExceptionHandler: returns NOT_FOUND typed GraphQL error
- ProfileApiTest: add tests for follow, unfollow, and get profile with
  nonexistent users

Addresses MDD-78

Co-Authored-By: unknown <>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

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.

1 participant