netplan should specify the version of YAML that it takes as input

Bug #1901084 reported by Dan Watkins
6
This bug affects 1 person
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://yaml.org/type/int.html) whereas YAML 1.2 dropped support for base 60 integers.

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_load(yaml.dump({"x": "11:22:33:44:55:59"}))
Out[4]: {'x': '11:22:33:44:55:59'}

# The value roundtrips correctly if only 1.2 is used
In [6]: ruamel.yaml.safe_load(ruamel.yaml.dump({"x": "11:22:33:44:55:59"}))
Out[6]: {'x': '11:22:33:44:55:59'}

# The value is interpreted as a base60 integer if 1.2 is the dumper and 1.1 is the loader
In [8]: yaml.safe_load(ruamel.yaml.dump({"x": "11:22:33:44:55:59"}))
Out[8]: {'x': 8846009759}
```

The key difference is in the quoting:

```
In [10]: yaml.dump({"x": "11:22:33:44:55:59"})
Out[10]: "x: '11:22:33:44:55:59'\n"

In [11]: ruamel.yaml.dump({"x": "11:22:33:44:55:59"})
Out[11]: '{x: 11:22:33:44:55:59}\n'
```

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.