canonical / canonical/cloud-init
Schema error messaging doesn't handle 'anyof' with 'required'
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 22
Description
An example under the `cc_yum_add_repo` properties:
```
"anyOf": [
{
"required": [
"baseurl"
]
},
{
"required": [
"metalink"
]
}
]
```
This provides the desired validation result, but if you exclude both baseurl and metalink, the error doesn't include both properties:
```
# cloud-init schema -t cloud-config -c a.yaml
Invalid user-data a.yaml
Error: Cloud config schema errors: yum_repos.epel-testing: 'baseurl' is a required property
Error: Invalid schema: user-data
```
We should have a way of messaging that `baseurl` or `metalink` is required, not just `baseurl`.
Contributor guide
Research direction
Reproduce the reported case with `cloud-init schema -t cloud-config -c a.yaml` using the `cc_yum_add_repo` properties example. Trace the schema validation error handling for `anyOf` entries containing `required`; done means the error clearly reports that either `baseurl` or `metalink` is required.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100