# Troubleshooting

`helm-schema` is alpha. It works for many charts, but Helm templates have many edge cases, such as
dynamic keys, helpers that build values at render time, and behavior that only shows when Helm runs.
Treat a generated schema as a strong start to review, and expect some charts to need an
[override](https://romnn.github.io/helm-schema/docs/guide/overrides/).

## A value is typed loosely or not at all

Look at standard error first: `helm-schema` says why it could not type a resource, as a
[diagnostic](https://romnn.github.io/helm-schema/docs/reference/diagnostics/). Then, by cause:

- **`MissingSchema` for a custom resource:** add a
  [CRD catalog mirror](https://romnn.github.io/helm-schema/docs/guide/crd-schemas/#mirrors-and-caching) that has it, or put
  its schema in a [local override](https://romnn.github.io/helm-schema/docs/guide/crd-schemas/#local-overrides).
- **`MissingSchema` for an API that recent Kubernetes removed:** add
  [`--k8s-version-fallback auto`](https://romnn.github.io/helm-schema/docs/guide/kubernetes-schemas/#automatic-version-fallback).
- **The `apiVersion` could not be pinned:** try
  [`--api-version-guess`](https://romnn.github.io/helm-schema/docs/guide/kubernetes-schemas/#apiversion-inference).
- **Anything else:** tighten the value with an [override schema](https://romnn.github.io/helm-schema/docs/guide/overrides/).

## A guard does not make a value a boolean

`{{ if .Values.x }}` accepts more than `true`: Helm treats `false`, `0`, `""`, an empty list and an
empty map as false, and everything else as true. The schema says exactly that, as an `anyOf` of the
non-empty forms. A value only becomes a `boolean` when something types it as one, such as a boolean
Kubernetes field. [Template analysis](https://romnn.github.io/helm-schema/docs/guide/template-analysis/#truthiness) shows an
example.

## An integer is an `anyOf` of an integer and a string

Helm renders a quoted number where a number is expected: `replicas: "2"` renders the same as
`replicas: 2`. The string member, with a numeric `pattern`, accepts that form, so the schema does
not reject values Helm renders.

## A value is required

The schema requires a value that the templates always render, where a missing value would fail the
render or produce an invalid resource. Helm checks the values merged with the chart's defaults, so a
key the chart's `values.yaml` sets is only missing when a user removes it by setting it to `null`.

`--infer-required` adds more:
[Required fields](https://romnn.github.io/helm-schema/docs/guide/values-and-defaults/#required-fields) says which.

## A values file passes, and `helm template -f` still fails

One schema has to serve every way values reach Helm, and they differ. `--set replicas=3` gives a
template an integer, while the same number in a values file arrives as a float, and some templates,
such as a `range` over a count, accept one and fail on the other. The schema accepts every value
some way renders, so a number that only works through `--set` passes validation.

`helm-schema` warns about such a value with `InputChannelNumericRangeAmbiguity`. Run CI values
files through a real `helm template -f` as well.

## Helm refuses the schema as too large

Helm refuses any chart file over 5 MiB. By default `helm-schema` switches to compact JSON with
short definition names when the readable schema would be larger, and says so on standard error.
When even that is too large, or validating it is slow:

- **The `lean` profile:** drops document-level conditions; see
  [Configuration](https://romnn.github.io/helm-schema/docs/reference/configuration/).
- **`--strip-descriptions`:** drops the Kubernetes descriptions.
- **`helm-schema lint` and `helm-schema template`:** run Helm on a copy of the chart with a shortened
  schema, so you can keep the readable one; see [Output](https://romnn.github.io/helm-schema/docs/reference/output/#size-limit).

## Reporting a wrong inference

Open an [issue](https://github.com/romnn/helm-schema/issues) with the chart, or a small chart that
shows the problem, the schema you got, and what you expected.
