Skip to content

Missing required field goes unreported when its path shares a prefix with an absent optional field - #1057

Merged
wilkinsona merged 1 commit into
spring-projects:mainfrom
hunseonglee:gh-1054
Sep 30, 2026
Merged

wilkinsona merged 1 commit into
spring-projects:mainfrom
hunseonglee:gh-1054

Conversation

@hunseonglee

Copy link
Copy Markdown

Fixes gh-1054

JsonContentHandler.isNestedBeneathMissingOptionalField used a plain string prefix test, so a required field whose path merely shared a string prefix with an absent optional field's path (optional a + required ab, or optional a.b + required a.bc) was treated as nested beneath it, and findMissingFields() never reported it — the snippet was generated with the missing required field undetected. resolveFieldType was affected the same way.

The check now requires the descendant path to continue with a . or [ segment boundary after the ancestor path. Added regression tests that fail on main and pass with the fix; all payload tests and spring-restdocs-core checks pass.

@wilkinsona wilkinsona changed the title Consider segment boundaries when checking for a missing optional ancestor Missing required field goes unreported when its path shares a prefix with an absent optional field Sep 3, 2026
@wilkinsona wilkinsona added this to the 4.0.x milestone Sep 30, 2026
@wilkinsona wilkinsona added type: bug A bug and removed status: waiting-for-triage Untriaged issue labels Sep 30, 2026
…stor

isNestedBeneathMissingOptionalField used a plain string prefix test, so
a required field whose path merely shared a string prefix with an
absent optional field's path (for example optional 'a' and required
'ab') was treated as nested beneath it and its absence was never
reported.

Require the path to continue with a '.' or '[' segment boundary after
the ancestor path.

See spring-projectsgh-1057

Signed-off-by: seonghun lee <harrisleesh@gmail.com>
@wilkinsona
wilkinsona merged commit a658157 into spring-projects:main Sep 30, 2026
4 checks passed
@wilkinsona

Copy link
Copy Markdown
Member

Thanks again, @hunseonglee.

@wilkinsona wilkinsona modified the milestones: 4.0.x, 4.0.2 Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing required field goes unreported when its path shares a prefix with an absent optional field

3 participants