canonical / canonical/cloud-init

Schema error messaging doesn't handle 'anyof' with 'required'

Open
#5,502 1 comment 0 reactions 0 assignees View on GitHub
bug
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.