test(openidm-script): reproduce custom endpoint field projection collision (#183)#190
Open
vharseko wants to merge 1 commit into
Open
test(openidm-script): reproduce custom endpoint field projection collision (#183)#190vharseko wants to merge 1 commit into
vharseko wants to merge 1 commit into
Conversation
…ision (OpenIdentityPlatform#183) Add CustomEndpointFieldProjectionTest reproducing the field-projection bug from discussion OpenIdentityPlatform#183: a custom scripted endpoint returns the full object without setting response fields (like ScriptedRequestHandler.evaluate()), so the generic CREST projection Resources.filterResource() is applied to the raw result using request.getFields(). When two requested fields share the same leaf name on different nesting levels (userName and manager/userName), the nested one overwrote the top-level one, so top-level userName ended up holding the manager's userName. The test goes through the real path (Resources.newInternalConnection -> connection.read) and asserts the correct behaviour: - top-level userName keeps the user's own userName - manager/userName is nested under manager Fixed in commons: OpenIdentityPlatform/commons#183 Refs: OpenIdentityPlatform#183 (discussion)
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.
Description
What
Adds a regression test
openidm-script/src/test/java/org/forgerock/openidm/script/CustomEndpointFieldProjectionTest.javathat reproduces the custom-endpoint field-projection bug reported in
discussion #183.
Why
A custom (scripted) endpoint returns the full object without explicitly setting the
response fields (
ScriptedRequestHandler.evaluate()callsnewResourceResponse(id, null, resultJson)withoutaddField(...)). The generic CRESTprojection
Resources.filterResource(JsonValue, Collection<JsonPointer>)then collapsedeach requested pointer to its
leaf()name, somanager/userNameoverwrote thetop-level
userName.Reproduction
Request
?_fields=userName,manager,manager/userNameagainst a user that has amanager:{ "userName": "<manager's userName — WRONG>", "manager": { "userName": "<manager's userName — correct>" } }How the test works
RequestHandler(FullObjectEndpoint) mimics a scripted endpoint and returnsthe full nested object without
addField(...).Resources.newInternalConnection(...), and areadis issued with_fields=description,userName,givenName,sn,manager,manager/userName.userName== user's ownuserNamemanager/userName== manager'suserName(nested undermanager)Before the fix (commons 3.1.1-SNAPSHOT) the test fails:
Fix
The root cause is fixed in commons:
OpenIdentityPlatform/commons#183.
With the updated
json-resource, the generic projection preserves theJsonPointerstructure and this test passes.
Related