Handle empty HUGGING_FACE_TOKEN gracefully#422
Merged
MaxGhenis merged 1 commit intoPolicyEngine:masterfrom Jan 17, 2026
Merged
Conversation
- Treat empty string same as None (fixes CI with missing secrets) - Check os.isatty(0) before prompting - return None in non-interactive environments instead of hanging on getpass - Update return type to str | None This fixes the 'httpx.LocalProtocolError: Illegal header value b'Bearer '' error that occurs when Dependabot PRs run without access to secrets. Closes PolicyEngine/policyengine-uk#1479 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
10272f3 to
1e709ba
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #422 +/- ##
==========================================
+ Coverage 81.14% 82.41% +1.27%
==========================================
Files 197 201 +4
Lines 10228 10517 +289
Branches 1057 1064 +7
==========================================
+ Hits 8299 8668 +369
+ Misses 1640 1574 -66
+ Partials 289 275 -14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
None(fixes CI with missing secrets)os.isatty(0)before prompting - returnNonein non-interactive environments instead of hanging ongetpassstr | NoneProblem
When Dependabot opens a PR in repos using policyengine-core, it doesn't have access to repository secrets. The
HUGGING_FACE_TOKENsecret gets passed as an empty string"", which causes:get_or_prompt_hf_token()checksif token is None:- but""is notNone""hf_hub_downloadtries to useBearerheader (empty token)httpxfails withIllegal header value b'Bearer 'Solution
Related
Test plan
🤖 Generated with Claude Code