Skip to content

feat: add values.schema.json for strict Helm values validation#95

Open
christhegrand wants to merge 3 commits intopgdogdev:mainfrom
christhegrand:feat/values-schema-validation
Open

feat: add values.schema.json for strict Helm values validation#95
christhegrand wants to merge 3 commits intopgdogdev:mainfrom
christhegrand:feat/values-schema-validation

Conversation

@christhegrand
Copy link
Copy Markdown

Summary

  • Adds a values.schema.json (JSON Schema) that covers all 157 top-level values properties used across templates
  • Uses additionalProperties: false at every object level so typos and misspelled field names are caught at helm install/helm upgrade time instead of being silently dropped
  • Includes type constraints, enums (e.g. logLevel, logFormat, pullPolicy), and range validations where applicable

Motivation

Without a schema, Helm silently ignores unknown values keys. A misspelled field name (e.g. iamge instead of image) passes without error and the intended configuration is never applied.

Validation

  • helm lint . passes with default values
  • helm template renders successfully with default values and examples/full-example.yaml
  • Unknown properties are correctly rejected:
    $ helm template test . --set wrongFieldName=true
    Error: values don't meet the specifications of the schema(s):
    - (root): Additional property wrongFieldName is not allowed
    
    $ helm template test . --set iamge.tag=latest
    Error: values don't meet the specifications of the schema(s):
    - (root): Additional property iamge is not allowed
    

Test plan

  • helm lint . passes
  • helm template test . renders successfully
  • helm template test . -f examples/full-example.yaml renders successfully
  • helm template test . --set typoField=true is rejected
  • Verify no legitimate values are blocked by the schema

🤖 Generated with Claude Code

Adds a JSON Schema that validates all 157 top-level values properties
with additionalProperties: false at every object level. This catches
typos and misspelled field names at install/upgrade time instead of
silently dropping them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@levkk
Copy link
Copy Markdown
Contributor

levkk commented May 8, 2026

Nice. How are you generating this?

The schema is now generated by scripts/generate-schema.py which:
- Scans all templates for .Values.* references
- Infers types from template context (pgdog.intval → integer, toYaml → object, etc.)
- Merges manually maintained overrides from scripts/schema-overrides.yaml
  (enums, descriptions, required fields, complex array item schemas)
- Supports --check mode for CI to detect stale schemas

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@christhegrand
Copy link
Copy Markdown
Author

I added a 'generate schema' script together with an 'overrides' file for some other fields that the script was having trouble inferring properly.

@levkk
Copy link
Copy Markdown
Contributor

levkk commented May 8, 2026

Aight, let's try this! Thanks for writing it up.

Edit: Woops, couple CI failures (the test job)

@christhegrand
Copy link
Copy Markdown
Author

I'll fix the failures.

queryParser was inferred as object due to `with .Values.queryParser`
in the template — added explicit type: string override.

otel.headers uses `range $k, $v` which doesn't match any object-detection
pattern — added type: object override.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants