Skip to content

Consider nested property paths when filtering Querydsl parameters. - #2581

Open
lovrovrlec wants to merge 3 commits into
spring-projects:mainfrom
lovrovrlec:issue/2579-nested-querydsl-paths
Open

lovrovrlec wants to merge 3 commits into
spring-projects:mainfrom
lovrovrlec:issue/2579-nested-querydsl-paths

Conversation

@lovrovrlec

Copy link
Copy Markdown

Fixes the regression reported in #2579.

Since GH-2572, filterByJacksonVisibility matches each request parameter against a flat map of
top-level Jackson field names. A nested key such as address.street is never a key in that map, so
it is dropped and the endpoint silently degrades to findAll — a filtered request returns every row.
Nested paths are otherwise fully supported: QuerydslPredicateBuilder resolves them via
bindings.getPropertyPath(...), and they worked up to 5.0.5.

This resolves parameter names segment by segment, translating each segment through its own
MappedJacksonProperties so @JsonProperty renames keep working at depth, and rejecting the whole
parameter as soon as a segment is not exposed — extending the GH-2572 guarantee to nested paths
instead of weakening it.

Two tests, added in the first commit so the regression is visible on its own:

  • forwardsNestedPropertyPathsToQuerydsl fails before the fix (the parameter never reaches Querydsl).
  • doesNotExposeJsonIgnoredPropertiesNestedInAssociations passes before the fix only vacuously, and
    fails against a naive fix that forwards dotted keys unchecked — it pins the security property.

One deliberate decision worth your input: when a segment's owning type has no MappedJacksonProperties
(e.g. a map value), visibility cannot be established, so the parameter is rejected. This is stricter
than pre-5.0.5 behaviour, where such paths were forwarded and left to Querydsl's binding resolution to
reject. Happy to switch to forwarding them if you prefer the lenient variant.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 28, 2026
@lovrovrlec
lovrovrlec force-pushed the issue/2579-nested-querydsl-paths branch from 2b7cc83 to 25fbf84 Compare July 28, 2026 12:18
@mp911de
mp911de force-pushed the main branch 2 times, most recently from b048a81 to fae77f2 Compare August 5, 2026 14:13
Nested paths such as address.street are silently dropped since spring-projectsGH-2572, turning a filtered request into an unfiltered one. A second test pins the visibility guarantee to every segment of a nested path.

See spring-projectsGH-2579.

Signed-off-by: Lovro <lovro.vrlec@gmail.com>
Request parameters were matched against a flat map of top-level Jackson field names, so nested paths such as address.street never matched and were dropped, silently turning a filtered request into an unfiltered one.

Parameter names are now resolved segment by segment, rejecting the parameter as soon as a segment does not refer to an exposed property, so hidden properties remain unreachable through associations.

Closes spring-projectsGH-2579.

Signed-off-by: Lovro <lovro.vrlec@gmail.com>
@lovrovrlec
lovrovrlec force-pushed the issue/2579-nested-querydsl-paths branch from 25fbf84 to b14ca83 Compare September 17, 2026 08:32
Parameter names such as ".street", "address..street" or "address." tripped the Assert.hasText guard in MappedJacksonProperties.getPersistentProperty(…) and surfaced as an IllegalArgumentException for client-controlled input. A blank segment rejects the parameter, so it is dropped like any other unknown key.
The root type's MappedJacksonProperties is resolved once per request instead of once per parameter, as the lookup runs Jackson introspection on every call. resolvePath(…) guards its arguments consistently with the rest of the class.
Tests cover @JsonProperty renames at nested level and rejection beneath types without a property mapping; Address gains a renamed property for the former.
See spring-projectsGH-2579.

Signed-off-by: Lovro <lovro.vrlec@gmail.com>
@lovrovrlec
lovrovrlec force-pushed the issue/2579-nested-querydsl-paths branch from b14ca83 to 50e44b8 Compare September 17, 2026 08:41
@lovrovrlec
lovrovrlec requested a review from ruthst00 September 17, 2026 08:42
@lovrovrlec

Copy link
Copy Markdown
Author

@christophstrobl could you take a look at this when you next triage? It fixes a regression from GH-2572 (3dc76b8), reported in #2579.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants