[tasks/github] Guard against None GraphQL response in collect_releases#428
Open
MoralCode wants to merge 1 commit into
Open
[tasks/github] Guard against None GraphQL response in collect_releases#428MoralCode wants to merge 1 commit into
MoralCode wants to merge 1 commit into
Conversation
request_graphql_dict() can return None when the API call fails. The in-operator check on a NoneType raised TypeError. Added explicit None guards in fetch_data() and in the two call sites in releases_model() so the task logs a warning and returns cleanly instead of crashing. Fixes #3709 Signed-off-by: devs6186 <devyanshsomvanshi@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was originally filed as augurlabs/augur#3722 by @devs6186
Changeset
fetch_data()inreleases/core.pybefore the'data' in datacheckdata['data']['repository']itself is Nonefetch_data(..., True)call inreleases_model()against a None returnNotes
request_graphql_dict()can return None when the API call fails (network error, private repo, etc). Doingif 'data' in data:on a NoneType raisesTypeError: argument of type 'NoneType' is not iterable, which was crashing the collect_releases task. The fix logs a warning and returns cleanly rather than propagating an exception.The second None check (
data['data']['repository']can be None if GitHub returns{"data": {"repository": null}}for a repo that no longer exists) prevents a similar crash further down.Related issues/PRs
Description
This PR fixes #3709
Notes for Reviewers
Three small guard additions in the same file. No logic changes to the happy path.
Signed commits