netplan should specify the version of YAML that it takes as input
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Netplan |
New
|
Undecided
|
Unassigned |
Bug Description
In YAML 1.1, some MAC addresses can be interpreted as base 60 integers (per https:/
For people generating config programmatically, this could lead to issues if they are using a YAML 1.2 generator (and assuming netplan uses 1.1): their library will not quote such base 60 integers (because in YAML 1.2 they are unambiguously strings), and so a YAML 1.1 library will parse that value as an integer instead of a string.
PyYAML (`import yaml`) is YAML 1.1 where as `ruamel.yaml` is YAML 1.2:
```
In [1]: import yaml
In [2]: import ruamel.yaml
# The value roundtrips correctly if only 1.1 is used
In [4]: yaml.safe_
Out[4]: {'x': '11:22:
# The value roundtrips correctly if only 1.2 is used
In [6]: ruamel.
Out[6]: {'x': '11:22:
# The value is interpreted as a base60 integer if 1.2 is the dumper and 1.1 is the loader
In [8]: yaml.safe_
Out[8]: {'x': 8846009759}
```
The key difference is in the quoting:
```
In [10]: yaml.dump({"x": "11:22:
Out[10]: "x: '11:22:
In [11]: ruamel.
Out[11]: '{x: 11:22:33:
```