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

`cfn generate` - TypeError: unhashable type: 'OrderedSet'

Open x6j8x opened this issue 3 years ago • 8 comments

Hi,

we have a "oneOf" entry in our model and I suspect this to be culprit (but I don't know for sure).

With older versions of cfn-cli and the go-plugin this is generated just fine. But it breaks for 2.0.4 with the error above.

Complete stacktrace:

[2021-03-24T10:24:47Z] DEBUG    - Unhandled exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/rpdk/core/cli.py", line 100, in main
    args.command(args)
  File "/usr/local/lib/python3.9/site-packages/rpdk/core/generate.py", line 15, in generate
    project.generate()
  File "/usr/local/lib/python3.9/site-packages/rpdk/core/project.py", line 408, in generate
    self._plugin.generate(self)
  File "/usr/local/lib/python3.9/site-packages/rpdk/go/codegen.py", line 171, in generate
    contents = template.render(models=models)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.9/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.9/site-packages/rpdk/go/templates/types.go.tple", line 15, in top-level template code
    {{ name|uppercase_first_letter }} {{ type|translate_type }} `json:",omitempty"`
  File "/usr/local/lib/python3.9/site-packages/rpdk/go/resolver.py", line 40, in translate_type
    return "*" + PRIMITIVE_TYPES[resolved_type.type]
TypeError: unhashable type: 'OrderedSet'

x6j8x avatar Mar 24 '21 10:03 x6j8x

@x6j8x Were you able to fix this issue?

SuperMohit avatar Nov 29 '22 01:11 SuperMohit

@SuperMohit Kind of… We pinned 2.0.3 and as this repo is more dead than alive, that’s not the worst solution. ymmv 🤷‍♂️

x6j8x avatar Nov 29 '22 01:11 x6j8x

@SuperMohit Thanks for the reply.

SuperMohit avatar Nov 29 '22 01:11 SuperMohit

@x6j8x You mean 1.0.3 right?

SuperMohit avatar Nov 29 '22 01:11 SuperMohit

I can’t remember the exact circumstances (it’s been a long time), but we actually pin 2.0.3.

pip3 install -q --upgrade cloudformation-cli-go-plugin==2.0.3

x6j8x avatar Nov 29 '22 02:11 x6j8x

@x6j8x Thanks it works with 2.0.3.

SuperMohit avatar Nov 29 '22 15:11 SuperMohit

Just tried out 2.0.4 with the latest cloudformation-cli version (0.2.28 I believe), and this error seems to magically have disappeared. (I just checked that out to get rid of the invalid_create contract test from https://github.com/aws-cloudformation/cloudformation-cli/pull/734).

FlorianSW avatar Feb 02 '23 08:02 FlorianSW

actually for my case, even with 2.0.3, although contract test passed but on deploying template it would throw extraneous key all over. So had to remove polymorphic props.

SuperMohit avatar Mar 07 '23 16:03 SuperMohit