schema: tracecback when using schema --annotate on single line dicts
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Expired
|
Medium
|
Unassigned |
Bug Description
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-
#cloud-config
chef: {install_type: 1}
EOF
Annotate works on dicts that are not declared on the same line as the "chef" key
cat > invalid-chef.yaml <<EOF
#cloud-config
chef:
install_type: 1
EOF
csmith@
#cloud-config
chef:
install_type: 1 # E1
# Errors: -------------
# E1: 1 is not of type 'string'
csmith@
Traceback (most recent call last):
File "/home/
validate_
File "/home/
raise SchemaValidatio
cloudinit.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/
return _run_code(code, main_globals, None,
File "/usr/lib/
exec(code, run_globals)
File "/home/
return_value = main(sys.argv)
File "/home/
retval = util.log_time(
File "/home/
ret = func(*args, **kwargs)
File "/home/
validate_
File "/home/
print(
File "/home/
errors_
KeyError: 'chef.install_type'
Changed in cloud-init: | |
status: | New → Triaged |
status: | Triaged → Confirmed |
Changed in cloud-init: | |
status: | Confirmed → Triaged |
Another example:
```yaml
#cloud-config
users:
- name: james
hashed-passwd: somepassword
```
from https:/ /github. com/canonical/ cloud-init/ pull/1549# pullrequestrevi ew-1028680743