Skip to content

fix: adding a check to prevent path collisions - #55328

Open
shawkins wants to merge 1 commit into
keycloak:mainfrom
shawkins:iss54684
Open

shawkins wants to merge 1 commit into
keycloak:mainfrom
shawkins:iss54684

Conversation

@shawkins

Copy link
Copy Markdown
Contributor

closes: #54684

@shawkins
shawkins marked this pull request as ready for review November 19, 2026 15:03
@shawkins
shawkins requested review from a team as code owners November 19, 2026 15:03
Copilot AI balanced review requested due to automatic review settings November 19, 2026 15:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The collision guard misses inherited allOf fields and indirect descendants, allowing conflicting properties to pass undetected.

2 open issues
What changed in this PR

Adds a safeguard during Admin API v2 OpenAPI processing to reject conflicting field names in polymorphic representations, addressing #54684.

Changes:

  • Validates duplicate properties across a parent and its directly listed subtypes, excluding the discriminator.
  • Adds tests for permitted fields and collisions between siblings or with the base type.
File Description
rest/​admin-v2/​services/​src/​test/​java/​org/​keycloak/​admin/​internal/​openapi/​OASModelFilterPolymorphismTest.java Adds focused polymorphic field-validation tests.
rest/​admin-v2/​services/​src/​main/​java/​org/​keycloak/​admin/​internal/​openapi/​OASModelFilter.java Adds conflicting-field validation to discriminator processing.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 19, 2026 15:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Inherited-property overwrites, inconsistent nested discriminator handling, and missed indirect descendants leave collision validation and discriminator propagation incorrect.

3 open issues
2 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 19, 2026 17:37
closes: keycloak#54684

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The uniqueness test misses lookup-only query paths such as auth.method, allowing ambiguous query resolution to go undetected.

1 open issue
3 resolved since last review

Review effort: Balanced

Comment on lines +34 to +35
Set<String> shared = new TreeSet<>(OIDCClientModelSchema.INSTANCE.getAttributes().keySet());
shared.retainAll(SAMLClientModelSchema.INSTANCE.getAttributes().keySet());
Copilot AI balanced review requested due to automatic review settings November 19, 2026 17:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The uniqueness test checks only registered attribute keys, so it can miss collisions in representation properties and lookup-only subattribute paths.

2 open issues

Review effort: Balanced

Comment on lines +30 to +40
@Test
void protocolSchemasOnlyShareBaseClientAttributes() {
Set<String> baseAttributes = new BaseOnlySchema().getAttributes().keySet();

Set<String> shared = new TreeSet<>(OIDCClientModelSchema.INSTANCE.getAttributes().keySet());
shared.retainAll(SAMLClientModelSchema.INSTANCE.getAttributes().keySet());
shared.removeAll(baseAttributes);

assertEquals(Set.of(), shared,
"Field paths must be unique across the protocol schemas; declare shared fields in BaseClientModelSchema instead");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prohibit same field names in polymorphic representations

2 participants