refactor: use make_graphql_headers in pat_handler _test_pat_against_repo#1164
Merged
anderdc merged 2 commits intoMay 12, 2026
Merged
Conversation
Follow-up to entrius#499, which introduced make_graphql_headers and replaced two inline {'Authorization': f'Bearer {token}', ...} dicts in github_api_tools.py. validator/pat_handler.py._test_pat_against_repo still built the same dict inline. Switch the one remaining call site to the canonical helper so all GraphQL Authorization headers are constructed in one place. The helper adds an explicit 'Content-Type: application/json' header — requests.post sets the same value automatically from the json= kwarg, so this is not a behaviour change for this request.
Contributor
Author
anderdc
approved these changes
May 12, 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
Follow-up to merged #499, which introduced
make_graphql_headers(token)ingittensor/utils/github_api_tools.pyand replaced two inline{'Authorization': f'Bearer {token}', 'Content-Type': 'application/json'}dicts inexecute_graphql_queryandget_github_graphql_query.gittensor/validator/pat_handler.py::_test_pat_against_repostill builds the same dict inline:This is the one GraphQL
Authorization: Bearer …header construction in the codebase that doesn't usemake_graphql_headers.grep -rn "'Authorization': f'Bearer"confirms only this site and the helper's own definition remain.Switching to
make_graphql_headers(pat)puts every GraphQL Authorization header through one factory. The helper adds an explicit'Content-Type': 'application/json'header —requests.post(..., json=...)already sets the same value automatically from thejson=kwarg, so the wire request is unchanged.Net: +2 / -2 lines, single file.
Type of Change
Testing
pytest tests/— all 1491 tests pass.Checklist