{{ message }}
fix(elm): reject null for optional non-nullable properties - #3474
Merged
Conversation
An optional property with a non-nullable type decoded with `Jdec.nullable`, so an explicit `null` silently became `Nothing`. Use `Jdec.map Just` instead: absent keys still yield `Nothing`, but `null` is rejected. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

A JSON Schema optional property with a non-nullable type (
"value": { "type": "string" }underadditionalProperties: false) accepted an explicit{"value":null}: Elm generatedoptionalField "value" (Jdec.nullable Jdec.string) Nothing, sonulldecoded toNothingand round-tripped as{}instead of failing. It now generatesoptionalField "value" (Jdec.map Just Jdec.string) Nothing, which rejectsnullwhile an absent key still yieldsNothing. Nullable property types keepJdec.nullable.Coverage: removes
optional-property.schemafrom Elm'sskipSchema, enabling the shared fixture's three samples, including the expected-failure inputoptional-property.1.fail.json.Validation:
npm run build;CPUs=1 QUICKTEST=true FIXTURE=schema-elm npm run test:fixtures -- test/inputs/schema/optional-property.schema(3 files);CPUs=2 QUICKTEST=true FIXTURE=schema-elm npm run test:fixtures(87 tests);CPUs=2 QUICKTEST=true FIXTURE=elm npm run test:fixtures(57 tests, includes thearray-type: arrayrenderer-option variant);npm run lint.Production change: 1 line added, 1 removed.
🤖 Generated with Claude Code