fix(github): harden cross-referencing PR parser against null GraphQL fields - #1582
Conversation
|
@anderdc @LandynDev whenever you have a moment — small null-safety bug fix. |
f458c48 to
0a976a0
Compare
…fields
_search_issue_referencing_prs_graphql parses GitHub's GraphQL timeline for
PRs that reference an issue. Two nullable fields were dereferenced unguarded,
and either one raises AttributeError/TypeError that propagates to
find_prs_for_issue's outer handler and collapses the whole lookup to the None
"lookup failed" sentinel — so one bad node hides every other valid submission
for that issue:
- timelineItems.nodes elements are nullable (GitHub returns a null element when
the cross-reference lives in a repo the token can't see). `node.get('source')`
then crashes, and a literal `"nodes": null` makes `for node in None` raise.
- PullRequest.baseRepository is nullable (null when the base repo was deleted).
`pr.get('baseRepository', {}).get('nameWithOwner', '')` returns None from the
present-but-null key, so `.get('nameWithOwner')` crashes.
Guard both the same way the sibling functions in this file already do:
_select_current_close_event / _closing_issue_numbers_for_repo skip null nodes
and use `.get('nodes', []) or []`; _solver_from_closed_event guards
baseRepository with `(x or {}).get(...) or ''`.
Add regression tests covering a null node element, a null nodes list, and a
null baseRepository (mixed with a valid PR, and alone).
0a976a0 to
3f68c2f
Compare
|
@anderdc @LandynDev — sorry to ping here, but I emailed x9entrius@gmail.com ~10h ago with no reply and this is time-sensitive. My SN74 miner wallet's seed was stolen. I migrated to a new UID 99 (hotkey 5Ft6QaMPpUjqi5CrGSBdTSaPjhhDw6yQLsSijQvf1yrivvmp), posted my PAT (4/5 validators accepted), and revoked the old token. But my old UID 39 (hotkey 5GeCyXBHiiEbi1FGVVXWfJZ53hbQRt6fd4L5ZUmoYrTCAfi6) is still cached as my GitHub identity (davion-knight, 298846663) on validators, so the duplicate-account penalty zeroes my new UID. Could you deregister/blacklist UID 39 or restart validators to clear the cache? Been stuck ~24h. Thank you 🙏 |
Summary
_search_issue_referencing_prs_graphqlparses GitHub's GraphQL timeline for the PRs that cross-reference an issue. Two nullable GraphQL fields were dereferenced without a guard, and either one raises an exception that propagates tofind_prs_for_issue's outer handler and collapses the whole lookup to theNone"lookup failed" sentinel — so a single bad node hides every other valid submission for that issue:timelineItems.nodeselements are nullable — GitHub returns anullelement when the cross-reference lives in a repo the token can't see (redacted item).node.get('source')then raisesAttributeError, and a literal"nodes": nullmakesfor node in NoneraiseTypeError.baseRepository.PullRequest.baseRepositoryis nullable (comes backnullwhen the PR's base repo has been deleted/is inaccessible).pr.get('baseRepository', {}).get('nameWithOwner', '')returnsNonefrom the present-but-nullkey, so.get('nameWithOwner')raisesAttributeError.Both are guarded the same way the sibling functions in this same file already handle them:
_select_current_close_event/_closing_issue_numbers_for_reposkip null nodes (if not node: continue) and use.get('nodes', []) or []._solver_from_closed_eventguardsbaseRepositorywith(x or {}).get('nameWithOwner') or ''.Related Issues
None.
Type of Change
Testing
TestSearchIssueReferencingPrsGraphqlexercises the real parser for a null node element, a nullnodeslist, and a nullbaseRepository(mixed with a valid PR, and alone). Each fails ontestbefore the fix and passes after.ruff+pyrightclean.Checklist