Skip to content

Generate and enforce JSON Schema constraints for FlatBuffer configurations #485

Description

@kssim

Product Increment Description

Background

Runtime backend configuration is defined using versioned FlatBuffer schemas.
The repository can generate a JSON Schema representation, but constraints
documented in FBS comments are not yet reflected in the generated schema, and
JSON input is not validated before the binary FlatBuffer is produced.

PR #483 introduces a common approach for JSON Schema generation and validation.
This task should build on that mechanism rather than introducing a separate
implementation.

Related review:
#357 (comment)

Scope

  • Align the implementation with the approach introduced by PR Crypto configuration concept , extend crypto configuration schema and add JSON validation before serialization #483.
  • Define or reuse the supported FBS comment annotations for JSON Schema
    constraints.
  • Propagate supported constraints into the generated JSON Schema, such as:
    • required values;
    • minimum string lengths;
    • minimum array sizes;
    • supported enum values;
    • applicable patterns or numeric ranges.
  • Validate JSON configuration against the generated schema before invoking
    FlatBuffers binary generation.
  • Stop binary generation with an actionable error when schema validation fails.
  • Add positive and negative tests for schema generation and JSON validation.
  • Document the annotation format and the configuration generation workflow.

Dependency

This task should be implemented after, or in coordination with, PR #483 so that
both use the same annotation, generation, and validation mechanism.

Acceptance Criteria (DoD)

  • The implementation reuses or extends the mechanism introduced by PR Crypto configuration concept , extend crypto configuration schema and add JSON validation before serialization #483.
  • FBS comment-based constraints are present in the generated JSON Schema.
  • Invalid JSON input is rejected before a binary configuration is generated.
  • Valid JSON input continues to generate the expected FlatBuffer binary.
  • Validation failures identify the invalid field and violated constraint.
  • Bazel targets and CI cover schema generation and validation.
  • Runtime-only semantic checks that cannot be expressed in JSON Schema remain
    in the backend parser and are clearly documented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions