Skip to content

[Bug] find_prs_for_issue treats GraphQL lookup failures as zero submissions #1492

@kiannidev

Description

@kiannidev

Description

When GitHub GraphQL cross-reference lookup fails, _search_issue_referencing_prs_graphql correctly returns None (rate limit, network error, GraphQL errors, missing issue payload). The public wrapper find_prs_for_issue collapses that failure sentinel to an empty list via return prs or [].

Downstream, gitt issues submissions --json then emits a successful response with "submission_count": 0 — indistinguishable from a genuinely empty submission list.

This is inconsistent with other paths in the same module that preserve None for retry/failure signaling, e.g. find_solver_from_closure_event and check_github_issue_closed (solver_lookup_failed=True).

Steps to Reproduce

  1. Set GITTENSOR_MINER_PAT to a valid token.
  2. Run gitt issues submissions --id <active_issue_id> --json for an issue that has open referencing PRs on GitHub.
  3. Simulate GraphQL failure (rate limit, timeout, or mock _search_issue_referencing_prs_graphql returning None).

Actual: JSON like:

{"success": true, "submission_count": 0, "submissions": []}

Expected: Lookup failure should be distinguishable from “no submissions exist” — error / retry guidance, not false success.

Affected code

Failure sentinel (correct): gittensor/utils/github_api_tools.py ~272–284 — _search_issue_referencing_prs_graphql returns None on GraphQL failure.

Collapse bug: gittensor/utils/github_api_tools.py ~337:

prs = _search_issue_referencing_prs_graphql(...)
return prs or []   # ← turns None into []

CLI consumer: gittensor/cli/issue_commands/helpers.py fetch_open_issue_pull_requests passes the list through unchanged.

JSON output: gittensor/cli/issue_commands/submissions.py always sets 'success': True when no exception is raised.

Tests encode current behavior: tests/utils/test_github_api_tools.py expects [] when GraphQL raises — no coverage for None meaning failure.

Suggested fix

Stop coercing None to [] in find_prs_for_issue (one-line change), then handle None in fetch_open_issue_pull_requests / --json mode with an explicit error payload (same pattern as #1357 / #1358 for gitt issues list).

Impact

  • Bounty submitters/operators may believe nobody has submitted when GitHub lookup actually failed.
  • Monitoring/automation on --json output gets false negatives.

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions