kubeval icon indicating copy to clipboard operation
kubeval copied to clipboard

Invalid label values not caught

Open JohnPaton opened this issue 6 years ago • 2 comments

The only non-alphanumeric characters that can be in label values are . and -, but if you add

metadata:
  labels:
    test: this/should/fail

to some object it will still pass.

Trying to apply it yields

invalid: metadata.labels: Invalid value: "this/should/fail": a valid label must be
an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start
and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345',
regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

Versions:

  • kubeval 0.14.0
  • kubectl 1.14.6
  • Kubernetes 1.12.9

JohnPaton avatar Oct 16 '19 11:10 JohnPaton

Moreover, the values must be 63 chars or less. See #175

nvtkaszpir avatar Apr 13 '21 10:04 nvtkaszpir

Is this something y'all could prioritize? We just tripped on this with a label accidentally ending with -

james-pollard-leapyear avatar Jun 02 '21 18:06 james-pollard-leapyear