Fix field projection collapsing nested JsonPointers to leaf names#183
Merged
vharseko merged 1 commit intoJun 10, 2026
Merged
Conversation
Resources.filterResource(JsonValue, Collection<JsonPointer>) built the
projection using field.leaf() as a flat key, so a nested pointer such as
"manager/userName" lost its nesting and overwrote the same-named top-level
field. Requesting _fields=userName,manager,manager/userName caused the
top-level userName to be replaced by manager/userName.
Use JsonValue.putPermissive(field, value) so each requested pointer is written
back under its full path, preserving nesting and creating parent objects on
demand. Same-named leaf fields at different nesting levels no longer collide.
The empty pointer still copies all fields, shallow-copy semantics are kept, and
unresolved (e.g. array-index) pointers are skipped without regression.
Update the Javadoc to document the nesting-preserving behavior and extend
ResourcesTest with a leaf-name collision case
([userName, manager, manager/userName] over
{ userName: "bjensen", manager: { userName: "jdoe" } }).
Refs: OpenIdentityPlatform/OpenIDM#183
maximthomas
approved these changes
Jun 10, 2026
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.
Summary
Resources.filterResource(JsonValue, Collection<JsonPointer>)built theprojected result using
field.leaf()as a flat key:As a result, a nested pointer (e.g.
manager/userName) lost its nesting andwas stored under the leaf name (
userName), overwriting the same-namedtop-level field. With
_fields=userName,manager,manager/userName, thetop-level
userNamewas replaced by the value ofmanager/userName.This affected any
RequestHandlerthat does not set the response fieldsexplicitly (e.g. custom scripted OpenIDM endpoints), because the projection is
performed in
InternalConnectionviaResources.filterResource(response, request.getFields()).Changes
Resources.filterResource(JsonValue, Collection<JsonPointer>)now usesJsonValue.putPermissive(field, value)so each requestedJsonPointeriswritten back under its full path, preserving nesting. Missing parent objects
are created on demand, and same-named leaf fields at different nesting levels
no longer collide.
field.isEmpty()) still copies all resource fields.value.getObject()).are skipped, so there is no regression for that case.
structure of the requested fields and that same-named leaf fields at
different levels do not conflict.
ResourcesTest:testFilterDatarows that encoded the old flat behavior to thecorrect nested structure.
(
testFilterPreservesNestedFieldsWithCollidingLeafNames) and a data rowcovering the leaf-name collision:
fields = [userName, manager, manager/userName]over{ userName: "bjensen", manager: { userName: "jdoe" } }must yield
result.userName == "bjensen"andresult.manager.userName == "jdoe".Behavior
Before:
{ "userName": "jdoe", "manager": { "userName": "jdoe" } }After:
{ "userName": "bjensen", "manager": { "userName": "jdoe" } }Testing
mvn -o test -Dtest=ResourcesTestincommons/rest/json-resource— all 106tests pass.
Related
Once an updated commons
3.1.1-SNAPSHOTis published, the OpenIDM testopenidm-script/.../CustomEndpointFieldProjectionTestwill pass.See OpenIDM discussion:
OpenIdentityPlatform/OpenIDM#183