fix: return readable errors for unrecognised JSON fields#580
Merged
dricazenck merged 6 commits intoWomen-Coding-Community:mainfrom Mar 29, 2026
Merged
Conversation
Unknown fields in request payloads currently surface as generic parse failures, which makes API validation errors harder to understand and debug. Handle unreadable JSON with a clearer message that points to the exact field path and lists the allowed properties so invalid requests can be corrected quickly.
The new JSON error handler was only covered for unknown fields, which left the generic HttpMessageNotReadableException fallback behavior untested. Add a regression test for an invalid enum value so future changes do not accidentally alter the fallback error contract.
The feedback section is refreshed with testimonials from the 2025 mentorship cycle, replacing the 2024 entries to keep the displayed content current and relevant for prospective mentors and mentees. The `link` field is also reordered before `items` in the mentor and mentee sections to match a consistent field ordering convention used across the CMS content schema.
src/main/java/com/wcc/platform/configuration/GlobalExceptionHandler.java
Show resolved
Hide resolved
src/main/java/com/wcc/platform/configuration/GlobalExceptionHandler.java
Show resolved
Hide resolved
src/main/java/com/wcc/platform/configuration/GlobalExceptionHandler.java
Show resolved
Hide resolved
src/test/java/com/wcc/platform/configuration/GlobalExceptionHandlerTest.java
Show resolved
Hide resolved
womencodingcommunity
approved these changes
Mar 23, 2026
Contributor
womencodingcommunity
left a comment
There was a problem hiding this comment.
Great work on this PR! The GlobalExceptionHandler improvement is well-structured — the pattern-matched instanceof, sorted allowed-fields list, and the integration test going through the full MockMvc stack all give good confidence in the behaviour. The mentorship page refresh and JSON field reordering are clean too.
Warnings to address before or shortly after merge:
import com.wcc.platform.domain.exceptions.*;— replace with the explicit imports that are actually needed; this will likely fail the PMDAvoidStarImportcheck.formatPathparameter usesjava.util.Listinline — add animport java.util.List;and use the short name.
Info / optional follow-ups (no blocker):
- The error path currently ends with the field name itself (
skills.areas[0].name), making it slightly redundant with the field name in the message prefix — see the inline suggestion for how to trim to the parent location. assertThrowsis used to capture a setup exception rather than as an assertion — a try-catch reads more clearly in that role.
|
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.



Description
When the API received a request body containing unknown JSON fields, it previously returned an opaque or unhelpful error response that gave
clients no actionable information. This fix adds proper handling in
GlobalExceptionHandlerfor deserialization failures so that clientsreceive a clear error message identifying the unrecognised field. This improves the developer experience when integrating with the API and
reduces debugging friction. The mentorship page feedback content is also refreshed with 2025 cycle testimonials and link field ordering is
aligned with the CMS schema convention.
Related PR
Women-Coding-Community/wcc-frontend#259
Change Type
Pull request checklist
Please check if your PR fulfills the following requirements: