kubernetes: yaml may fail to parse spuriously
What happened: JSON with comments in it (IE Yaml) will be “detected” as JSON because it matches ^\s+{.* in the first 100 bytes and be parsed as JSON even though it is valid YAML instead.
What you expected to happen: We should parse valid YAML as YAML. We should probably parse everything as YAML since it is a superset of JSON.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
The code is here:
Thread in slack: https://kubernetes.slack.com/archives/C13J86Z63/p1560351860082800
Environment: n/a
cc @smarterclayton @dims @liggitt @Katharine @chuckha /sig apimachinery
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 15 (12 by maintainers)
we need to be super sure that doesn’t regress performance or correctness (some yaml-related normalization issues at https://github.com/kubernetes/kubernetes/issues/73655 and https://github.com/kubernetes-sigs/yaml/pull/14)
For the sake of completeness, here is a valid yaml file that won’t work:
This isn’t valid JSON because it has a comment and trailing commas, but it is valid yaml, and should be treated as such.