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

fix(organizations): Handle non existent policy #3319

Conversation

jfagoagas
Copy link
Member

Description

Handle JSON policy returned by describe_policy when an exception is caught.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jfagoagas jfagoagas added the provider/aws Issues/PRs related with the AWS provider label Jan 26, 2024
@jfagoagas jfagoagas self-assigned this Jan 26, 2024
@jfagoagas jfagoagas requested a review from a team as a code owner January 26, 2024 08:20
Copy link

codecov bot commented Jan 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (dff3e72) 85.87% compared to head (a251b01) 85.90%.
Report is 22 commits behind head on master.

❗ Current head a251b01 differs from pull request most recent head 2941c34. Consider uploading reports for the commit 2941c34 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3319      +/-   ##
==========================================
+ Coverage   85.87%   85.90%   +0.02%     
==========================================
  Files         564      565       +1     
  Lines       18257    18292      +35     
==========================================
+ Hits        15679    15714      +35     
  Misses       2578     2578              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

except Exception as error:
logger.error(
f"{self.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
)
finally:
return policy_content_json
return json.loads(policy_content)

def __list_targets_for_policy__(self, policy_id):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to check in this function if policy_id is not None too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Member

@sergargar sergargar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@sergargar sergargar merged commit c6e8a0b into master Feb 5, 2024
6 checks passed
@sergargar sergargar deleted the unbound-local-error-105-cannot-access-local-variable-policy-content branch February 5, 2024 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider/aws Issues/PRs related with the AWS provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants