← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1879356] Re: `cloud-init devel schema --annotate` fails for integer keys which do not roundtrip through string representation

 

Tracked in Github Issues as https://github.com/canonical/cloud-
init/issues/3685

** Bug watch added: github.com/canonical/cloud-init/issues #3685
   https://github.com/canonical/cloud-init/issues/3685

** Changed in: cloud-init
       Status: Triaged => Expired

-- 
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/1879356

Title:
  `cloud-init devel schema --annotate` fails for integer keys which do
  not roundtrip through string representation

Status in cloud-init:
  Expired

Bug description:
  When using the new snap.commands schema (introduced in
  https://github.com/canonical/cloud-init/pull/364), it's possible to
  trigger a bug in our assertion code.  Specifically, this file will
  fail validation (correctly, because `123` is an integer and not a
  string):

    #cloud-config
    snap:
        commands:
            01: ["foo", 123]

  And then traceback during annotation:

    $ cloud-init devel schema -c foo.yaml --annotate
    Traceback (most recent call last):
      File "/home/daniel/dev/cloud-init/cloudinit/config/schema.py", line 217, in validate_cloudconfig_file
        validate_cloudconfig_schema(
      File "/home/daniel/dev/cloud-init/cloudinit/config/schema.py", line 121, in validate_cloudconfig_schema
        raise SchemaValidationError(errors)
    cloudinit.config.schema.SchemaValidationError: Cloud config schema errors: snap.commands.1: ['foo', 123] is not valid under any of the given schemas

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/daniel/.virtualenvs/cloud-init/bin/cloud-init", line 11, in <module>
        load_entry_point('cloud-init', 'console_scripts', 'cloud-init')()
      File "/home/daniel/dev/cloud-init/cloudinit/cmd/main.py", line 891, in main
        retval = util.log_time(
      File "/home/daniel/dev/cloud-init/cloudinit/util.py", line 2618, in log_time
        ret = func(*args, **kwargs)
      File "/home/daniel/dev/cloud-init/cloudinit/config/schema.py", line 446, in handle_schema_args
        validate_cloudconfig_file(
      File "/home/daniel/dev/cloud-init/cloudinit/config/schema.py", line 221, in validate_cloudconfig_file
        print(annotated_cloudconfig_file(
      File "/home/daniel/dev/cloud-init/cloudinit/config/schema.py", line 153, in annotated_cloudconfig_file
        errors_by_line[schemapaths[path]].append(msg)
    KeyError: 'snap.commands.1'

  Note the `1` at the end of the key we're looking for (instead of 01).
  If we modify the input file to drop the leading 0:

    #cloud-config
    snap:
        commands:
            1: ["foo", 123]

  then we don't see a traceback:

    $ cloud-init devel schema -c foo.yaml --annotate
    #cloud-config
    snap:
        commands:
            1: ["foo", 123]		# E1

    # Errors: -------------
    # E1: ['foo', 123] is not valid under any of the given schemas

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1879356/+subscriptions



References