canonical / canonical/cloud-init
schema: tracecback when using schema --annotate on single line dicts
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 22
Description
This bug was originally filed in Launchpad as [LP: #1885598](https://bugs.launchpad.net/cloud-init/+bug/1885598)
Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = None
date_created = 2020-06-29T16:18:15.900486+00:00
date_fix_committed = None
date_fix_released = None
id = 1885598
importance = medium
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1885598
milestone = None
owner = chad.smith
owner_name = Chad Smith
private = False
status = triaged
submitter = chad.smith
submitter_name = Chad Smith
tags = ['bitsize']
duplicates = []
_Launchpad user **Chad Smith(chad.smith)** wrote on 2020-06-29T16:18:15.900486+00:00_
Annotate doesn't handle r-value dicts that begin on the same line as the l-value key.
Given the following example invalid cloudconfig (providing an int for a string value in chef), we get a traceback when trying to annotate the invalid user-data.
cat > invalid-chef-traceback.yaml < invalid-chef.yaml <
return_value = main(sys.argv)
File "/home/csmith/src/cloud-init/cloudinit/cmd/main.py", line 891, in main
retval = util.log_time(
File "/home/csmith/src/cloud-init/cloudinit/util.py", line 2285, in log_time
ret = func(*args, **kwargs)
File "/home/csmith/src/cloud-init/cloudinit/config/schema.py", line 444, in handle_schema_args
validate_cloudconfig_file(
File "/home/csmith/src/cloud-init/cloudinit/config/schema.py", line 219, in validate_cloudconfig_file
print(annotated_cloudconfig_file(
File "/home/csmith/src/cloud-init/cloudinit/config/schema.py", line 151, in annotated_cloudconfig_file
errors_by_line[schemapaths[path]].append(msg)
KeyError: 'chef.install_type'
Contributor guide
Research direction
Start in cloudinit/config/schema.py, especially annotated_cloudconfig_file and the schema command path shown in the traceback. Reproduce the issue with a single-line dict such as chef: {install_type: 1}, then verify that devel schema --annotate reports the validation error without raising a KeyError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100