canonical / canonical/cloud-init

[docs]: example contains type-ambiguous YAML

Open Beginner friendly
#6,984 0 comments 0 reactions 0 assignees View on GitHub
documentation
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

The YAML example at [doc/examples/cloud-config-ansible-controller.txt](https://github.com/canonical/cloud-init/blob/a6d999ae517d62d2d557d7b2b4d8dd403abdde35/doc/examples/cloud-config-ansible-controller.txt#L82) contains some lines with values that vary in type according to which version of YAML is used to read them:
```
permissions: 0o600
```

The octal numeric type syntax `0o777` was added in YAML 1.2, and as of that version
the above line is interpreted as a number with decimal value 384. But the schema
defines that field [as string](https://github.com/canonical/cloud-init/blob/a6d999ae517d62d2d557d7b2b4d8dd403abdde35/cloudinit/config/schemas/schema-cloud-config-v1.json#L3673).

The YAML file in question doesn't declare any YAML version, so this can result in a type error
when a YAML 1.2 or later parser is used to read the file and then verified against the schema.

This could easily be fixed by using explicit quotes or a `!!str` annotation.

Contributor guide

Open the contributing guide

Research direction

Open doc/examples/cloud-config-ansible-controller.txt around line 82 and compare the permissions value with cloudinit/config/schemas/schema-cloud-config-v1.json around line 3673. Check how YAML 1.2 parses the example, then make the value unambiguously a string. Done means schema validation accepts the example without a type error.

Written by the indexing model from the issue text.

Assessment

Tech stack
yaml
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.