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

Uncaught exception on cfn generate Key Error

Open letsbelopez opened this issue 4 years ago • 1 comments

I'm getting an uncaught exception when generating my types using cfn generate with version 0.2.20

Here's the error log:

[2021-10-25T23:36:02Z] DEBUG    - Unhandled exception
Traceback (most recent call last):
  File "/usr/local/Cellar/cloudformation-cli/0.2.20/libexec/lib/python3.10/site-packages/rpdk/core/cli.py", line 100, in main
    args.command(args)
  File "/usr/local/Cellar/cloudformation-cli/0.2.20/libexec/lib/python3.10/site-packages/rpdk/core/generate.py", line 15, in generate
    project.generate()
  File "/usr/local/Cellar/cloudformation-cli/0.2.20/libexec/lib/python3.10/site-packages/rpdk/core/project.py", line 438, in generate
    self._plugin.generate(self)
  File "/usr/local/Cellar/cloudformation-cli/0.2.20/libexec/lib/python3.10/site-packages/rpdk/java/codegen.py", line 36, in wrapper
    result = func(*args, **kwargs)
  File "/usr/local/Cellar/cloudformation-cli/0.2.20/libexec/lib/python3.10/site-packages/rpdk/java/codegen.py", line 401, in generate
    models = resolve_models(project.schema)
  File "/usr/local/Cellar/cloudformation-cli/0.2.20/libexec/lib/python3.10/site-packages/rpdk/core/jsonutils/resolver.py", line 230, in resolve_models
    return model_resolver.resolve_models()
  File "/usr/local/Cellar/cloudformation-cli/0.2.20/libexec/lib/python3.10/site-packages/rpdk/core/jsonutils/resolver.py", line 88, in resolve_models
    models[class_name] = {
  File "/usr/local/Cellar/cloudformation-cli/0.2.20/libexec/lib/python3.10/site-packages/rpdk/core/jsonutils/resolver.py", line 89, in <dictcomp>
    prop_name: self._schema_to_lang_type(prop_schema)
  File "/usr/local/Cellar/cloudformation-cli/0.2.20/libexec/lib/python3.10/site-packages/rpdk/core/jsonutils/resolver.py", line 104, in _schema_to_lang_type
    return ResolvedType(ContainerType.MODEL, self._models[ref_path])
KeyError: ('definitions', 'ThemeValues')

Here's my schema definitions

"definitions": {
        "CreateThemeData": {
            "type": "object",
            "properties": {
                "Values": {
                    "$ref": "#/definitions/ThemeValues"
                },
                "Tags": {
                    "$ref": "#/definitions/Tags"
                },
                "Name": {
                    "type": "string",
                    "maxLength": 255,
                    "minLength": 1
                }
            },
            "required": [
                "Name",
                "Values"
            ],
            "additionalProperties": false
        },
        "Tags": {
            "type": "object",
            "patternProperties": {
                "^(?!aws:)[a-zA-Z+-=._:/]+$": {
                    "type": "string",
                    "maxLength": 256,
                    "minLength": 1
                }
            },
            "additionalProperties": false
        },
        "Theme": {
            "type": "object",
            "properties": {
                "AppId": {
                    "type": "string"
                },
                "EnvironmentName": {
                    "type": "string"
                },
                "CreatedAt": {
                    "type": "string",
                    "format": "date-time"
                },
                "Values": {
                    "$ref": "#/definitions/ThemeValues"
                },
                "Id": {
                    "type": "string"
                },
                "Tags": {
                    "$ref": "#/definitions/Tags"
                },
                "Name": {
                    "type": "string",
                    "maxLength": 255,
                    "minLength": 1
                }
            },
            "required": [
                "AppId",
                "CreatedAt",
                "EnvironmentName",
                "Id",
                "Name",
                "Values"
            ],
            "additionalProperties": false
        },
        "ThemeValue": {
            "type": "object",
            "properties": {
                "Value": {
                    "type": "string"
                },
                "Children": {
                    "$ref": "#/definitions/ThemeValues"
                }
            },
            "additionalProperties": false
        },
        "ThemeValues": {
            "type": "object",
            "patternProperties": {
                "^\\w+$": {
                    "$ref": "#/definitions/ThemeValue"
                }
            },
            "additionalProperties": false
        },
        "UpdateThemeData": {
            "type": "object",
            "properties": {
                "Values": {
                    "$ref": "#/definitions/ThemeValues"
                },
                "Id": {
                    "type": "string"
                },
                "Name": {
                    "type": "string",
                    "maxLength": 255,
                    "minLength": 1
                }
            },
            "required": [
                "Values"
            ],
            "additionalProperties": false
        }
    }

letsbelopez avatar Oct 25 '21 23:10 letsbelopez

it looks like the issues with recursive pattern properties

ammokhov avatar Dec 02 '21 19:12 ammokhov