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

Safely Access Dictionary Key in Logging Output #35

Merged
merged 1 commit into from
Sep 29, 2021

Conversation

mcdonnnj
Copy link
Member

@mcdonnnj mcdonnnj commented Sep 29, 2021

πŸ—£ Description

This changes a dictionary access to use the get() method so a default value is returned if the key is missing.

πŸ’­ Motivation and context

GitHub Actions runs for the lineage_scan workflow are currently failing because cisagov/con-pca-api is missing the version field in its .github/lineage.yml file and we do not safely access that key in the parsed configuration dictionary. This can be seen at this point in the log. Although that repository needs to be fixed, it should not result in a failing state for this Action.

πŸ§ͺ Testing

Automated tests pass.

βœ… Checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All relevant type-of-change labels have been added.
  • I have read the CONTRIBUTING document.
  • These code changes follow cisagov code standards.
  • All new and existing tests pass.

This changes a logging output to get a default value if the desired key is
absent.
@mcdonnnj mcdonnnj added the bug This issue or pull request addresses broken functionality label Sep 29, 2021
@mcdonnnj mcdonnnj self-assigned this Sep 29, 2021
Copy link
Member

@jsf9k jsf9k left a comment

Choose a reason for hiding this comment

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

Nice catch!

Copy link
Member

@dav3r dav3r left a comment

Choose a reason for hiding this comment

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

Nice catch πŸ¦… πŸ‘€

@mcdonnnj mcdonnnj merged commit 2bead11 into develop Sep 29, 2021
@mcdonnnj mcdonnnj deleted the bug/safely_handle_missing_key branch September 29, 2021 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue or pull request addresses broken functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants