fix(github): harden cross-reference PR parser against null GraphQL fields#1575
Open
codevector96 wants to merge 1 commit into
Open
fix(github): harden cross-reference PR parser against null GraphQL fields#1575codevector96 wants to merge 1 commit into
codevector96 wants to merge 1 commit into
Conversation
…elds
`_search_issue_referencing_prs_graphql` read `baseRepository` with
`pr.get('baseRepository', {}).get('nameWithOwner', '')`. GitHub's GraphQL
API returns the key present with an explicit `null` (e.g. when a referencing
PR's base repo was deleted or is inaccessible), so the chained `.get` raised
`AttributeError`. `find_prs_for_issue` swallows that into the lookup-failure
sentinel, so one unresolvable timeline node made the whole issue's submission
lookup report as failed instead of skipping that node.
Mirror the null-guarding the sibling closure-event helpers already use
(`_select_current_close_event`, `_solver_from_closed_event`): guard null
timeline nodes, null `timelineItems`, and null `baseRepository`.
Adds regression tests exercising each null path directly.
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.
Summary
_search_issue_referencing_prs_graphqlread the PR base repo withpr.get('baseRepository', {}).get('nameWithOwner', ''). The{}default onlyapplies when the key is absent — GitHub's GraphQL API returns the key
present with an explicit
null(e.g. when a referencing PR's base repositorywas deleted or is inaccessible). In that case the chained
.getruns onNoneand raises
AttributeError.find_prs_for_issuewraps this call inexcept Exception -> return None(the lookup-failure sentinel). So a single unresolvable timeline node made the
entire issue's submission lookup report as "GitHub lookup failed" instead of
skipping that one node and returning the valid PRs — the exact failure mode the
recent read-failed/empty-submissions work (#1492/#1554) was tightening.
The sibling closure-event helpers in the same file already guard these nulls
correctly (
_select_current_close_eventusesif node and ...and.get('nodes', []) or [];_solver_from_closed_eventuses((closer.get('baseRepository') or {}).get('nameWithOwner') or '')). This PRbrings the cross-reference parser in line with that convention:
timelineItems→ treated as no nodesbaseRepository→ skipped (not fatal)Related Issues
None — surfaced while reading the issue-submission lookup path.
Type of Change
Testing
Adds
TestSearchIssueReferencingPRsGraphQLcovering each null path directly:a
baseRepository: nullPR node is skipped while valid PRs still return, anulltimeline node is skipped, and anulltimelineItems payload yields[]instead of raising. Existing tests unchanged.
ruff check/ruff formatclean.
Checklist