Ranging over a map puts "*" into the map's required properties

Open
#4 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
57/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
helm, json, rust
Domain
cli, devops

Research direction

Start by tracing how the Rust schema generator handles range expressions and maps field reads onto JSON Schema properties; the payload does not name implementation files or tests. Reproduce with the provided chart and helm lint repro, then check that ranged map values are represented through additionalProperties or patternProperties and no "*" is added to required, including inside conditional branches.

Written by the indexing model from the issue text.

Description

bug

Observed

When a template ranges over a map and reads a field of each entry, helm-schema puts * (its name for "every key of this map") into the map's required list. No values can satisfy that, so Helm rejects even the chart's own defaults.

Found in opentelemetry-collector 0.178.2, templates/_config.tpl, which ranges over telemetry.resourceAttributes.default the same way.

Reproduction

Chart.yaml:

apiVersion: v2
name: repro
version: 0.1.0

values.yaml:

attributes:
  first:
    enabled: true
    value: a
  second:
    value: b

templates/configmap.yaml:

apiVersion: v1
kind: ConfigMap
metadata:
  name: repro
data:
{{- range $name, $attribute := .Values.attributes }}
{{- if dig "enabled" true $attribute }}
  {{ $name }}: {{ $attribute.value | quote }}
{{- end }}
{{- end }}
helm-schema repro > repro/values.schema.json
helm lint repro
- at '': 'allOf' failed
  - at '/attributes': missing property '*'
Error: 1 chart(s) linted, 1 chart(s) failed

The generated schema contains, among others:

"then": {
  "properties": {
    "attributes": { "type": "object", "required": ["*"] }
  }
}

required: ["*"] also appears under /allOf/0/if/properties/attributes. Because of that, the if branch can never match, so its then is silently disabled as well.

Expected

A field read from each entry of a ranged-over map constrains the map's values (additionalProperties, or patternProperties with .*), not a property literally named *. Nothing should be added to the map's required list.

Notes

  • Reproduced with helm-schema 0.0.7, the current release.
  • A --override-schema can't reach the copy inside the conditional branch. Downstream, the romnn/cluster lint now strips "*" from every required list after generation, as a workaround (without_wildcard_requirements in scripts/lint_kubernetes.py).
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.