Validate config JSON against schema#919
Open
Symmetricity wants to merge 2 commits into
Open
Conversation
Read the config schema from resources/config-schema.json and embed it at build time so tilemaker can validate configs without relying on a runtime schema path. This catches missing or mistyped settings before Config::readConfig dereferences RapidJSON values, and improves parse errors by including RapidJSON's parse reason and byte offset. Co-authored-by: Codex <noreply@openai.com>
The Docker build stage runs CMake before the runtime stage copies resources, so the generated config schema header could not be created inside Docker after adding config validation. Copy only the schema file into the build stage to keep Docker cache invalidation narrow while making the CMake build match local builds. Co-authored-by: Codex <noreply@openai.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.
This PR was prepared with AI assistance.
Tilemaker now validates config JSON against a schema before reading required
settings from it.
The schema lives in
resources/config-schema.jsonso it can be read, reviewed,and reused by editors or external validation tools. The build embeds that schema
into
tilemaker:resources/config-schema.jsonand generatesconfig_schema.hinthe build directory.
src/config_schema.hfrom the same schema file.make clean.This avoids a runtime dependency on finding a schema file while still keeping
the schema separate from the C++ code.
Why
Invalid config files could previously fail in two unhelpful ways:
Invalid JSON file.Config::readConfig, where unchecked RapidJSON access could assert.This specifically improves the cases reported in #867 and #875. For example,
the config attached to #875 is now rejected before
readConfigwith:Other examples now include:
Testing
make test_config_validatorcmake -S . -B ... -DCMAKE_BUILD_TYPE=RelWithDebInfocmake --build ... --parallel 8make testgit diff --check