yannh / kubeconform

A FAST Kubernetes manifests validator, with support for Custom Resources!
Apache License 2.0
2.07k stars 116 forks source link

Zero exit code on malformed yamls #230

Closed mhr3 closed 10 months ago

mhr3 commented 11 months ago

We use kubeconform in our CI, and noticed that a malformatted yaml produces an error to stderr, yet the exit code is 0, which means our CI thinks everything is fine.

The error we get is:

...: MalformedYAMLError: yaml: line 26: mapping values are not allowed in this context in File: ./res.yaml
Summary: 0 resource found parsing stdin - Valid: 0, Invalid: 0, Errors: 0, Skipped: 0
% echo $?
0

this was with v0.6.1

yannh commented 11 months ago

Hi, what command line do you use? Any way to reproduce? Thanks!

mhr3 commented 11 months ago

It was kubeconform -summary -ignore-missing-schemas

There was an extra space in an env value:

          env:
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: LABEL_SELECTOR
               value: key=value
yannh commented 10 months ago

Hi @mhr3 , I'm struggling to reproduce, if there was a resource/file you could share that I could run Kubeconform on, that would be quite helpful! :bow:

yannh commented 10 months ago

@mhr3 I'll be closing this ticket because of the missing information.. I'd be quite interested in fixing this, but I would need clear steps to reproduce the issue! Feel free to reopen or open a new ticket with more infos :bow:

mhr3 commented 4 months ago

Ran into this again, but this time I noticed the error is coming from kustomize itself, but because we do kustomize build ... | kubeconform ... the error code gets swallowed.

Any chance to add a --disallow-empty? Or perhaps even to make that the default?