aws-cloudformation / cfn-lint

CloudFormation Linter
MIT No Attribution
2.43k stars 586 forks source link

Unable to generate graph using -g #2982

Open vennemp opened 8 months ago

vennemp commented 8 months ago

CloudFormation Lint Version

0.83.6

What operating system are you using?

MacOS - Apple Silicon

Describe the bug

I get the following error when I try to render a graph from my template.

`% cfn-lint vpc.yml -g

Traceback (most recent call last): File "/opt/homebrew/bin/cfn-lint", line 8, in sys.exit(main()) ^^^^^^ File "/opt/homebrew/Cellar/cfn-lint/0.83.6/libexec/lib/python3.12/site-packages/cfnlint/main.py", line 39, in main matches = list(cfnlint.core.get_matches(filenames, args)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/cfn-lint/0.83.6/libexec/lib/python3.12/site-packages/cfnlint/core.py", line 173, in get_matches matches = run_cli( ^^^^^^^^ File "/opt/homebrew/Cellar/cfn-lint/0.83.6/libexec/lib/python3.12/site-packages/cfnlint/core.py", line 69, in run_cli template_obj.build_graph() File "/opt/homebrew/Cellar/cfn-lint/0.83.6/libexec/lib/python3.12/site-packages/cfnlint/template/template.py", line 87, in build_graph self.graph.to_dot(path) File "/opt/homebrew/Cellar/cfn-lint/0.83.6/libexec/lib/python3.12/site-packages/cfnlint/graph.py", line 276, in to_dot view = self.settings.subgraph_view(self.graph) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/cfn-lint/0.83.6/libexec/lib/python3.12/site-packages/cfnlint/graph.py", line 48, in subgraph_view n for n, v in graph.nodes.items() if v["type"] in ["Resource"] ~^^^^^^^^ KeyError: 'type' `

Expected behavior

I want to generate a graph

Reproduction template

It is like this with all templates.

kddejong commented 8 months ago

Not able to reproduce using a pip install on Mac. Issue may be related to homebrew so I'll have to do some more testing.

All nodes should have a type https://github.com/aws-cloudformation/cfn-lint/blob/ac630a0307dd05bc1e217da81818ff544365da58/src/cfnlint/graph.py#L240C9-L250

We could use v.get("type") to be careful https://github.com/aws-cloudformation/cfn-lint/blob/ac630a0307dd05bc1e217da81818ff544365da58/src/cfnlint/graph.py#L48

vennemp commented 8 months ago

It definitely seems related to homebrew vs pip. After trying -g tag - it completely bricked my local install of python. Can't even using boto3 anymore...Gonna take a while to debug this - please let me know if you have any tips.