fix: block stale cache fallback on GraphQL PAT auth failures - #905
Conversation
d2e74f7 to
1b4f422
Compare
1b4f422 to
b5cee92
Compare
anderdc
left a comment
There was a problem hiding this comment.
Right bug, but the marker list is the brittle part — GitHub can rephrase any of those five strings and a real auth failure leaks back into cache fallback.
Simpler and more robust: in the non_resource_errors branch at gittensor/utils/github_api_tools.py:929, just always set failed_reason. Something like:
if non_resource_errors:
bt.logging.error(f'GraphQL errors: {non_resource_errors}')
miner_eval.failed_reason = f'GitHub GraphQL error: {non_resource_errors[0].get("message", "unknown")[:200]}'
miner_eval.github_pr_fetch_failed = True
breakThis branch only fires when GitHub returns 200 with errors that aren't RESOURCE_LIMITS_EXCEEDED. Every other transient class — network exceptions, 5xx, rate limits — hits a different branch and keeps cache fallback. So the GraphQL-errors-array path is overwhelmingly auth / scope / schema / permission failures, none of which should restore stale cached scores. A genuinely transient INTERNAL_SERVER_ERROR from GitHub eats one round at 0, which is recoverable next round.
Drop the marker tuple, the helper, and the auth-specific test. Keep the integration test in test_validator_cache_fallback.py but assert it works for any GraphQL error message, not just the auth phrasing.
@anderdc Updated. Non-resource GraphQL errors now always set |
Summary
Fixes stale cache fallback when a stored miner PAT passes REST
/uservalidation but fails the PR GraphQL query used during scoring with an auth/scope error.Previously,
load_miners_prs()marked these GraphQL failures withgithub_pr_fetch_failed=Truebut leftfailed_reason=None. Since cache fallback only skips miners withfailed_reason, validators could restore a previous successful cached evaluation and continue rewarding stale PRs even though the current PAT no longer had the GraphQL access required for scoring.This change detects clear GraphQL PAT auth/scope errors, such as
Resource not accessible by personal access token, marks the evaluation with a non-cacheablefailed_reason, and preserves cache fallback for transient/non-auth GraphQL failures.Related Issues
Closes #904
Type of Change
Testing
Commands run:
Checklist