Skip to content

Report errors and the version of valijson, and support draft 3 - #34

Open
Roman3349 wants to merge 1 commit into
bowtie-json-schema:mainfrom
Roman3349:report-errors-and-version
Open

Roman3349 wants to merge 1 commit into
bowtie-json-schema:mainfrom
Roman3349:report-errors-and-version

Conversation

@Roman3349

Copy link
Copy Markdown

The harness was compiled without VALIJSON_USE_EXCEPTIONS, so valijson called abort() whenever it could not parse a schema, for example when a reference cannot be resolved. As the harness did not catch exceptions either, a single such test case terminated it, and Bowtie then reported the other test cases of the same run as errored as well. On the current report, 22 test cases are errored for each of draft 4 and draft 7, of which only three are actual failures of valijson; the others, such as those for if/then/else and items, pass when run on their own.

Changes

  • Compile with -DVALIJSON_USE_EXCEPTIONS=1, and report an exception thrown while parsing the schema or validating an instance as an error for that test case, with its message as context. This also enables the regex format, which valijson only enforces when exceptions are enabled.
  • Include the RapidJSON adapter before the RapidJSON headers, so that valijson can define RAPIDJSON_ASSERT to throw rather than to abort.
  • Return no document for a URI that is not in the registry, rather than reading a missing member, so that valijson reports that the document could not be fetched.
  • Test a specific release of valijson, set with the VALIJSON_VERSION build argument, and report it as the implementation version, which the report currently shows as unknown. The harness previously built whichever commit was on master when the image happened to be rebuilt.
  • Add draft 3, which valijson supports with SchemaParser::kDraft3.

Testing

Ran the test cases of the latest JSON-Schema-Test-Suite through the harness with the Bowtie protocol, restarting it after a crash, against valijson 1.1.5:

Before After
Draft 4 3 crashes 2 crashes, 1 errored
Draft 7 3 crashes, 1527 correct results 2 crashes, 1 errored, 1535 correct results
Draft 3 not supported 2 crashes, 1 errored

The test case "anchor within remote ref" is now reported as errored, instead of terminating the harness. The two remaining crashes, for tag URIs and URIs with arbitrary schemes, are stack overflows in valijson that cannot be caught, and are fixed by tristanpenman/valijson#271, which is not released yet.

The Docker image builds, reports version 1.1.5 and the three dialects, and answers a test case with an unresolvable reference with an error.

Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
@Roman3349
Roman3349 force-pushed the report-errors-and-version branch from df4051c to 3532962 Compare December 3, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant