Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helper.transform_asg_style_tags() not protected when resource['values'] is None #567

Closed
joaoubaldo opened this issue Oct 6, 2021 · 2 comments
Assignees
Labels

Comments

@joaoubaldo
Copy link
Contributor

joaoubaldo commented Oct 6, 2021

Description

To Reproduce

The issue is a bit flaky. It doesn't look directly related with a specific resource (we are using terraform-compliance on a high number of cicd pipelines and this issue is only affecting a few of them)
Example: when generating a plan that applies the whole infrastructure from scratch it doesn't fail, however when the plan includes updates, terraform-compliance fails with the Exception:

        | Name | .+    |
          AttributeError: 'NoneType' object has no attribute 'get'

Feature File:
https://github.com/joaoubaldo/cli/blob/issue-567-handle-none-resource-values/tests/functional/test_issue-567/test.feature
Plan File:
https://github.com/joaoubaldo/cli/blob/issue-567-handle-none-resource-values/tests/functional/test_issue-567/plan.out.json

Used terraform-compliance Parameters:
I was able to isolate the issue by running radish directly with the parameters terraform-compliance uses.
bin/radish --write-steps-once /feature/directory/ --basedir /terraform_compliance/steps --user-data=plan_file=my-plan.tfplan.json --user-data=exit_on_failure=False --user-data=terraform_executable=None --user-data=no_failure=False --user-data=silence_mode_enabled=False --user-data=debugging_mode_enabled=False

Running via Docker:
No

Error Output:

        | Name | .+    |
          AttributeError: 'NoneType' object has no attribute 'get'

Expected Behavior:
Failed / passed scenarios without Exceptions.

Tested Versions:

  • terraform-compliance version: 1.3.29
  • terraform version: 1.0.2
  • python version: 3.9.7

Additional Context:
From what I was able to debug I have found a potential issue here

tag = resource.get('values', {}).get('tag')
)
When resource['values'] is None, the original Exception will be thrown.
I confirm that having a None protection here fixes my problem but I am not certain that having resource['values'] as None at this point means the issue should be fixed somewhere else first.

I'll create a PR and reference the issue.

@eerkunt
Copy link
Member

eerkunt commented Oct 13, 2021

Thanks a lot for the PR 🎉

Looks great.

@joaoubaldo
Copy link
Contributor Author

Issue is fixed in master. cc @eerkunt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants