Nested value objects stay open, so a misspelled nested key passes the schema

Open
#5 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
helm, rust
Domain
cli, devops, tooling

Research direction

Start by reading how helm-schema statically analyzes chart templates and generates nested object schemas, including the handling of .Values.image.repository and .Values.image.tag. Reproduce with the supplied chart and compare the generated schema under the default, lean, and full profiles. Done means image.tagg is rejected while objects consumed whole by toYaml, range, or another template remain open.

Written by the indexing model from the issue text.

Description

The generated schema closes the root object (additionalProperties: false), so a misspelled top-level key fails helm install. Every nested object stays open (additionalProperties: {}), though, even when the templates read each of its keys by name. So a misspelled nested key passes silently, and the chart renders with the default instead.

For example, a misspelled image.tag deploys the default image without any warning.

Repro

Chart.yaml:

apiVersion: v2
name: repro
version: 0.1.0

values.yaml:

replicaCount: 1
image:
  repository: nginx
  tag: "1.27"

templates/deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: repro
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: repro
  template:
    metadata:
      labels:
        app: repro
    spec:
      containers:
        - name: app
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
helm-schema . --output values.schema.json   # same with --profile lean and --profile full
helm template x . --set imagee.tag=oops      # rejected: additional properties 'imagee' not allowed
helm template x . --set image.tagg=oops      # accepted

With helm-schema 0.0.7, the generated schema has "additionalProperties": false at the root but "additionalProperties": {} on image.

Expected

An object whose keys the templates only ever read by name (.Values.image.repository, .Values.image.tag) should be closed like the root, so image.tagg is rejected.

It should stay open only where something consumes it whole, such as toYaml .Values.podAnnotations, range over it, or passing it to another template.

Dominant language
Rust
Stars
5
Forks
0
Avg merge
1h 31m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from romnn/helm-schema

All issues in romnn/helm-schema

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.