cloudformation-cli icon indicating copy to clipboard operation
cloudformation-cli copied to clipboard

cfn validate does not show a clear message to fix the schema

Open prerna-p opened this issue 5 years ago • 3 comments

I ran cfn validate against a resource schema with issues that should be caught by this fix. But the message is confusing. The message should be clear in what has to be fixed and that the schema is not valid.

cfn validate
[Warning] Resource spec validation would fail from next major version. Provider should mark additionalProperties as false if the property is of object type and has properties or patternProperties defined in it. Please fix the warnings: 'additionalProperties' is a required property

Failed validating 'required' in schema['properties']['definitions']['patternProperties']['^[A-Za-z0-9]{1,64}$']['allOf'][0]['dependencies']['properties']:
    {'$comment': 'An object cannot have both defined and undefined '
                 'properties; therefore, patternProperties is not allowed '
                 'when properties is specified. Provider should mark '
                 'additionalProperties as false if the property is of '
                 'object type and has properties defined in it.',
     'not': {'required': ['patternProperties']},
     'required': ['additionalProperties']}

On instance['definitions']['Tag']:
    {'description': 'A key-value pair to associate with a resource.',
     'properties': {'Key': {'description': 'The key name of the tag. You '
                                           'can specify a value that is 1 '
                                           'to 127 Unicode characters in '
                                           'length and cannot be prefixed '
                                           'with aws:. You can use any of '
                                           'the following characters: the '
                                           'set of Unicode letters, '
                                           'digits, whitespace, _, ., /, '
                                           '=, +, and -.',
                            'maxLength': 127,
                            'minLength': 1,
                            'type': 'string'},
                    'Value': {'description': 'The value for the tag. You '
                                             'can specify a value that is '
                                             '1 to 255 Unicode characters '
                                             'in length and cannot be '
                                             'prefixed with aws:. You can '
                                             'use any of the following '
                                             'characters: the set of '
                                             'Unicode letters, digits, '
                                             'whitespace, _, ., /, =, +, '
                                             'and -.',
                              'maxLength': 255,
                              'minLength': 1,
                              'type': 'string'}},
     'required': ['Value', 'Key'],
     'type': 'object'}
Resource schema is valid.

prerna-p avatar Feb 01 '21 19:02 prerna-p

had a similar comment here: https://github.com/aws-cloudformation/cloudformation-cli/pull/642#discussion_r561446814

Unfortunately, JSON schema messages only seem to leave the choice of way too much or way too little context

PatMyron avatar Feb 01 '21 19:02 PatMyron

Prerna, could you provide an example of what you mean by a clear message? What kind of messages would be helpful in improving the experience

anshikg avatar Apr 29 '21 16:04 anshikg

Prerna, could you provide an example of what you mean by a clear message? What kind of messages would be helpful in improving the experience

Recently when running validate I got the following message:

Explicitly specify value for taggable
Resource schema is valid

Which property is this message referring to? Is it possible to hide "Resource schema is valid." if there are warnings?

prerna-p avatar Jul 02 '21 02:07 prerna-p