Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 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
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Inherited-property overwrites, inconsistent nested discriminator handling, and missed indirect descendants leave collision validation and discriminator propagation incorrect.
3 open issues
Only direct$refentries are inspected, so an indirect descendant expressed as `allOf: [{allOf:… · New Nested discriminator fields are handled inconsistently: with outer discriminatortypeand branch… · New Merging inherited properties withputAllcan erase a conflicting declaration from an earlier… · New
2 resolved since last review
Review effort: Balanced
closes: keycloak#54684 Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Comment on lines
+34
to
+35
| Set<String> shared = new TreeSet<>(OIDCClientModelSchema.INSTANCE.getAttributes().keySet()); | ||
| shared.retainAll(SAMLClientModelSchema.INSTANCE.getAttributes().keySet()); |
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"); | ||
| } |
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.
closes: #54684