Repository navigation
Conversation
…rovider `schema-java-datetime-legacy` runs this schema, but CI's Java job runs only `java,schema-java`. A quick-test entry runs it in `schema-java` with `datetime-provider: legacy`, including the expected-failure sample `optional-date-time.1.fail.date-time.json`, which that provider accepts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`parseAllDateTimeString` returned `null` when no format matched, so an invalid date, time or date-time property was read as `null` instead of being rejected (`optional-date-time.1.fail.date-time.json` was accepted). Throw `IllegalArgumentException`, as the `java8` provider's parsers throw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Description
With
--datetime-provider legacy, the generatedConverter.parseAllDateTimeStringnow throwsIllegalArgumentException("Unparseable date: " + str)when no formatmatches, instead of returning
null. This is the one-line change inJavaLegacyDateTimeProvider(DateTimeProvider.ts).A second commit adds a quick-test entry to
JavaLanguage,["optional-date-time.schema", { "datetime-provider": "legacy" }], so theschema-javafixture that CI runs also runs this schema with the legacyprovider, including its expected-failure sample. Before this, only
schema-java-datetime-legacyran it, and CI does not run that fixture.Related Issue
Fixes #3549
Motivation and Context
An invalid
date,timeordate-timevalue was read asnull, sooptional-date-time.1.fail.date-time.jsonround-tripped with"required-date-time":nullinstead of failing. Thejava8provider'sparsers throw, and this makes the legacy provider do the same.
Previous Behaviour / Output
schema-java-datetime-legacyonoptional-date-time.schema:(exit status 0, with
"required-date-time":nullin the output).New Behaviour / Output
(exit status 1). The valid sample
optional-date-time.1.jsonstillround-trips. Every output generated with
--datetime-provider legacygets this line in
Converter.java; nothing else changes. Uniondeserializers call the parser inside an ignored
try/catch, so theybehave as before.
How Has This Been Tested?
Environment: macOS 26.6 (arm64), Node 24.16.0, OpenJDK 21.0.11 and
Maven 3.10.0 with
MAVEN_ARGS="-Dmaven.compiler.source=8 -Dmaven.compiler.target=8"(JDK 21 rejects the POM's source and target 1.6).
On this branch:
npm ci,npm run build,npm run lint(passes),npm run test:unit(54 files, 241 tests pass).
QUICKTEST=true FIXTURE=java,schema-java npm run test:fixtures: all 145runs pass (one input is skipped), including the new legacy entry.
QUICKTEST=true FIXTURE=schema-java-datetime-legacy npm run test:fixtures -- test/inputs/schema/optional-date-time.schema:passes.
With only the test commit (the fix reverted):
QUICKTEST=true FIXTURE=java,schema-java npm run test:fixturesfails onthe new entry with
Expected failure on input …optional-date-time.1.fail.date-time.json.schema-java-datetime-legacyonoptional-date-time.schemafails the same way.Note: the quick-test entries run only when the fixture is run without
sample arguments.
Screenshots (if appropriate):
n/a
Written by Claude (an AI assistant made by Anthropic) and posted on behalf of the account owner (EloB). The reproduction, fix and tests were checked by running them as described above.
🤖 Generated with Claude Code