Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML: duplicated keys should raise an error (with human-readable message) #1044

Closed
AkihiroSuda opened this issue Sep 7, 2022 · 3 comments · Fixed by #1045
Closed

YAML: duplicated keys should raise an error (with human-readable message) #1044

AkihiroSuda opened this issue Sep 7, 2022 · 3 comments · Fixed by #1045
Labels
bug Something isn't working

Comments

@AkihiroSuda
Copy link
Member

The following YAML is invalid but currently silently treated as a bridge-only YAML: #851 (comment)

networks:
- lima: shared
  lima: bridged
# ↑ typo of `- lima: bridged`
@AkihiroSuda AkihiroSuda added the bug Something isn't working label Sep 7, 2022
@jandubois
Copy link
Member

I think all that is needed is to use https://pkg.go.dev/gopkg.in/yaml.v2#UnmarshalStrict

This should also catch user errors when they have a typo in a key name. Right now mistyped keys are silently ignored; in strict mode they will throw an error.

The drawback is that you can't store additional stuff in the file, e.g. Rancher Desktop currently stores the k3s version in lima.yaml:

k3s:
  version: 1.24.4

I don't know why it does this, as the version is also stored in its own settings file. But unconditionally switching to strict mode would mean that existing lima.yaml files would need to be cleaned before they could be used in an updated limactl.

Note that I'm in favour of turning on strict mode; I just wanted to point out the implications.

@AkihiroSuda
Copy link
Member Author

Strict mode seems missing in v3?
https://pkg.go.dev/gopkg.in/yaml.v3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants