yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #83146
[Bug 1885598] [NEW] schema: tracecback when using schema --annotate on single line dicts
Public bug reported:
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 <<EOF
#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@uptown:~/src/cloud-init$ python3 -m cloudinit.cmd.main devel schema -c invalid-chef.yaml --annotate
#cloud-config
chef:
install_type: 1 # E1
# Errors: -------------
# E1: 1 is not of type 'string'
csmith@uptown:~/src/cloud-init$ python3 -m cloudinit.cmd.main devel schema -c invalid-chef-traceback.yaml --annotate
Traceback (most recent call last):
File "/home/csmith/src/cloud-init/cloudinit/config/schema.py", line 215, in validate_cloudconfig_file
validate_cloudconfig_schema(
File "/home/csmith/src/cloud-init/cloudinit/config/schema.py", line 120, in validate_cloudconfig_schema
raise SchemaValidationError(errors)
cloudinit.config.schema.SchemaValidationError: Cloud config schema errors: chef.install_type: 1 is not of type 'string'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/csmith/src/cloud-init/cloudinit/cmd/main.py", line 901, in <module>
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'
** Affects: cloud-init
Importance: Undecided
Status: Confirmed
** Changed in: cloud-init
Status: New => Triaged
** Changed in: cloud-init
Status: Triaged => Confirmed
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1885598
Title:
schema: tracecback when using schema --annotate on single line dicts
Status in cloud-init:
Confirmed
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-chef-traceback.yaml <<EOF
#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@uptown:~/src/cloud-init$ python3 -m cloudinit.cmd.main devel schema -c invalid-chef.yaml --annotate
#cloud-config
chef:
install_type: 1 # E1
# Errors: -------------
# E1: 1 is not of type 'string'
csmith@uptown:~/src/cloud-init$ python3 -m cloudinit.cmd.main devel schema -c invalid-chef-traceback.yaml --annotate
Traceback (most recent call last):
File "/home/csmith/src/cloud-init/cloudinit/config/schema.py", line 215, in validate_cloudconfig_file
validate_cloudconfig_schema(
File "/home/csmith/src/cloud-init/cloudinit/config/schema.py", line 120, in validate_cloudconfig_schema
raise SchemaValidationError(errors)
cloudinit.config.schema.SchemaValidationError: Cloud config schema errors: chef.install_type: 1 is not of type 'string'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/csmith/src/cloud-init/cloudinit/cmd/main.py", line 901, in <module>
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'
To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1885598/+subscriptions
Follow ups