Ignore uniqueItems when set to false while importing JSON Schema documents - #6924
Conversation
🦋 Changeset detectedLatest commit: c83020b The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Important
The reproduction test is correct and verifies the expected behavior, but the implementation fix at fromJsonSchemaDocument.ts:817 still needs to be applied.
Reviewed changes
- Reproduction test for
uniqueItems: false: Adds a test confirming thatuniqueItems: falsedoes not impose a uniqueness constraint —["a", "a"]should validate astrue. Confirmed the test correctly fails against the current code.
⚠️ Implementation fix still needed
The test is a faithful reproduction, but collectArrayChecks still adds isUnique for any boolean uniqueItems value.
Technical details
# Tighten `uniqueItems` guard to `true` only
## Affected sites
- `packages/effect/src/internal/schema/fromJsonSchemaDocument.ts:817` — `typeof schema.uniqueItems === "boolean"` pushes `isUnique` for both `true` and `false`, adding a uniqueness constraint even when it is explicitly disclaimed.
## Required outcome
- Change the guard so `uniqueItems: false` yields no `isUnique` check.
## Suggested approach
- Replace `typeof schema.uniqueItems === "boolean"` with `schema.uniqueItems === true` on line 817.
- No callers or tests should regress — the existing `uniqueItems: true` test at `fromJsonSchemaDocument.test.ts:1696` will continue to pass, and the new test will go green.DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
uniqueItems when set to false while importing JSON Schema documents
c0a7b6d to
c83020b
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Applied the
uniqueItems === trueguard: ChangedcollectArrayChecksfromtypeof schema.uniqueItems === "boolean"toschema.uniqueItems === trueso thatuniqueItems: falseno longer pushes anisUniquefilter. - Added patch changeset:
effectpatch-level changeset describing the fix.
The implementation matches the suggested fix from the prior review exactly. The new reproduction test passes, and the existing uniqueItems: true test is unaffected.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Summary
Importing a JSON Schema array with uniqueItems set to false rejects duplicate elements.
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.
uniqueItems false enables uniqueness
Module:
SchemaRepresentationAudit ID:
core-s-z-testing-schema-representation-unique-items-falseSeverity / confidence: medium / high
What happens
Importing a JSON Schema array with uniqueItems set to false rejects duplicate elements.
Why it happens
collectArrayChecks adds the effect/schema/isUnique filter for either boolean value, so the importer strengthens a valid external schema and rejects values it must accept.
Expected behavior
JSON Schema Draft 2020-12 uniqueItems: false imposes no uniqueness constraint.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/effect/src/internal/schema/fromJsonSchemaDocument.ts:811-820View problematic code at
packages/effect/src/internal/schema/fromJsonSchemaDocument.ts:811-820View exact lines on GitHub
Reproduction
Observed failure: validity false instead of true
Implementation handoff
The initial reproduction tests on this branch are the regression specification for the implementation fix that should follow in this PR.
Audit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715fcore-s-z-testing-schema-representation-unique-items-false