fix(exception-handling): Add ResourceNotFoundException handler for structured error responses [MDD-78]#369
Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Conversation
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 <>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
fix(exception-handling): Add ResourceNotFoundException handler [MDD-78]
Summary
Adds explicit
@ExceptionHandlerforResourceNotFoundExceptionin 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 throwResourceNotFoundException(ProfileApi, ArticleApi, CommentsApi, etc.).Changes:
CustomizeExceptionHandler: New handler returning404with{"message": "Resource not found"}GraphQLCustomizeExceptionHandler: Newelse ifbranch returningNOT_FOUNDtyped GraphQL errorProfileApiTest: 3 new tests for follow/unfollow/get-profile with nonexistent users, plusCustomizeExceptionHandleradded to test@ImportReview & Testing Checklist for Human
@ResponseStatusvs@ExceptionHandlerprecedence:ResourceNotFoundExceptionhas@ResponseStatus(HttpStatus.NOT_FOUND)on the class. Confirm that the new@ExceptionHandlertakes precedence in all cases (it should, but this is the highest-risk interaction). Consider whether the@ResponseStatusannotation should be removed now that there's an explicit handler.ResourceNotFoundExceptionusages app-wide (ArticleApi, CommentsApi, ArticleFavoriteApi, GraphQL datafetchers). Verify these endpoints still return 404 as expected with the new structured body.ResourceNotFoundException. Consider whether a test in the GraphQL layer is needed for confidence.Suggested manual test plan:
POST /profiles/nonexistent-user/followwith auth → expect404with{"message": "Resource not found"}DELETE /profiles/nonexistent-user/followwith auth → sameGET /profiles/nonexistent-user→ sameGET /articles/nonexistent-slug) to verify the handler works app-wideNotes