Preserve colliding definitions when sanitizing JsonSchema keys - #6905
Closed
fubhy wants to merge 1 commit into
Closed
Preserve colliding definitions when sanitizing JsonSchema keys#6905fubhy wants to merge 1 commit into
fubhy wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Reproduction test for component-key collision — adds a test that exposes the bug where
sanitizeOpenApiComponentsSchemasKeyproduces identical keys ("A_B") for distinct definition keys ("A$B"and"A B"), causing one definition to be dropped.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
Contributor
|
Fixed in #6883 |
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
Distinct canonical definitions whose names sanitize to the same OpenAPI component key are silently merged. One schema is discarded and references to both definitions alias the surviving component.
Important
This PR starts with focused failing reproduction tests. Add the implementation fix to this same branch; CI is expected to fail until that fix is included.
OpenAPI component-key sanitization merges definitions
Module:
JsonSchemaAudit ID:
core-g-r-jsonschema-component-key-collisionSeverity / confidence: high / high
What happens
Distinct canonical definitions whose names sanitize to the same OpenAPI component key are silently merged. One schema is discarded and references to both definitions alias the surviving component.
Why it happens
Invalid key characters are independently replaced with underscores, but the converter neither detects nor resolves collisions. A$B and A B both become A_B, and Rec.mapEntries emits only one property.
Expected behavior
toMultiDocumentOpenApi3_1 converts every canonical definition into a valid OpenAPI component and rewrites references to the corresponding converted definitions.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/effect/src/JsonSchema.ts:669-699packages/effect/src/JsonSchema.ts:703-735View problematic code at
packages/effect/src/JsonSchema.ts:669-699View exact lines on GitHub
View problematic code at
packages/effect/src/JsonSchema.ts:703-735View exact lines on GitHub
Reproduction
pnpm vitest run packages/effect/test/JsonSchema.test.ts -t "preserves definitions whose keys sanitize to the same component name"Observed failure: The intended failure was reproduced: one definition was emitted instead of two.
Implementation handoff
The initial reproduction tests on this branch are the regression specification for the implementation fix that should follow in this PR.
pnpm vitest run packages/effect/test/JsonSchema.test.ts -t "preserves definitions whose keys sanitize to the same component name"Audit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715fcore-g-r-jsonschema-component-key-collision