fix(api): adaptive GraphQL page size on 5xx + file changes retry#185
Merged
anderdc merged 5 commits intoentrius:testfrom Feb 13, 2026
Merged
Conversation
…e queries GitHub returns 502 when a GraphQL query is too expensive to process. Halve the page limit on 502/503/504 responses (floor of 10) before retrying, so the retry loop can self-heal instead of failing 8 times with the same oversized request.
This REST endpoint had no retry logic — a single transient failure would silently return an empty list, causing the PR to score 0. Add 3 attempts with exponential backoff (matching the pattern used by all other API functions in the module).
29a0e92 to
464a50f
Compare
anderdc
reviewed
Feb 13, 2026
LandynDev
reviewed
Feb 13, 2026
Address PR entrius#185 review feedback: remove redundant `and limit > 10` guard since `max(limit // 2, 10)` already floors at 10, and simplify the warning log from "reducing page size to" to "page size set to".
…s retry Address PR review feedback: change retry guard from `attempt < (max_attempts - 1)` to `attempt < max_attempts` and move error logging after the loop for clarity.
Contributor
Author
|
Updated the PR |
Collaborator
|
lgtm |
anderdc
approved these changes
Feb 13, 2026
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
get_pull_request_file_changes(3 attempts with exponential backoff) — previously a single transient failure silently returned an empty list, causing the PR to score 0Problem
The GraphQL PR query (
get_github_graphql_query) fetches ~20+ fields per PR including nested relations (closingIssuesReferences,reviews,repository,headRepository). At 100 PRs per page, this can exceed GitHub's server-side processing timeout for miners with many PRs, returning a 502. The existing retry loop retried 8 times at the same page size — all failing identically.Separately,
get_pull_request_file_changeshad zero retry logic. A single transient 502/timeout on this REST endpoint would silently return[], causing the entire PR to score 0 with no warning.Changes
gittensor/utils/github_api_tools.pyget_github_graphql_query(page size reduction):variablesdict inside the retry loop solimitcan update between attemptslimitbefore retrying (floor of 10)get_pull_request_file_changes(retry logic):RequestException(connection errors, timeouts)tests/utils/test_github_api_tools.pyAPI usage impact
These changes are budget-neutral in the happy path and net-positive under failures:
The per-PR scoring calls (
file_changes+file_contents) are the dominant API cost (~97% of calls), but at ~0.6% per validator per miner they are well within the ~5% target needed for 20-validator redundancy.Verified
Observed in production-like run — the 502 warning fires and self-heals:
Miner scored 1122.47 at Silver tier after recovery.
Test plan
pytest tests/utils/test_github_api_tools.py -v— 23 passedpytest tests/ -v— 210 passedcheck_miner_status.py— 502 recovery confirmed