Skip to content

Commit 3a9c139

Browse files
MaxGhenisclaude
andauthored
Handle missing HUGGING_FACE_TOKEN gracefully in CI (#1480)
Only export the token when it has a non-empty value. This prevents the 'httpx.LocalProtocolError: Illegal header value b'Bearer '' error that occurs when Dependabot PRs run without access to secrets. The token is passed via an intermediate env var (HF_TOKEN_VALUE) and only exported to HUGGING_FACE_TOKEN if non-empty, allowing tests that don't need microdata downloads to still pass. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 45dc44a commit 3a9c139

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

.github/workflows/code_changes.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,14 @@ jobs:
5050
- name: UV sync
5151
run: uv sync
5252
- name: Run tests with coverage
53-
run: make test
53+
run: |
54+
# Only export token if non-empty (defensive against missing secrets)
55+
if [ -n "$HF_TOKEN_VALUE" ]; then
56+
export HUGGING_FACE_TOKEN="$HF_TOKEN_VALUE"
57+
fi
58+
make test
5459
env:
55-
HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
60+
HF_TOKEN_VALUE: ${{ secrets.HUGGING_FACE_TOKEN }}
5661
- name: Upload coverage to Codecov
5762
uses: codecov/codecov-action@v4
5863
with:

.github/workflows/pr_code_changes.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,14 @@ jobs:
5050
- name: UV sync
5151
run: uv sync
5252
- name: Run tests with coverage
53-
run: make test
53+
run: |
54+
# Only export token if non-empty (avoids 'Bearer ' error for Dependabot PRs)
55+
if [ -n "$HF_TOKEN_VALUE" ]; then
56+
export HUGGING_FACE_TOKEN="$HF_TOKEN_VALUE"
57+
fi
58+
make test
5459
env:
55-
HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
60+
HF_TOKEN_VALUE: ${{ secrets.HUGGING_FACE_TOKEN }}
5661
- name: Upload coverage to Codecov
5762
uses: codecov/codecov-action@v4
5863
with:

changelog_entry.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- bump: patch
2+
changes:
3+
fixed:
4+
- CI workflows now handle missing HUGGING_FACE_TOKEN gracefully, allowing Dependabot PRs to run tests without failing on empty Bearer token errors.

0 commit comments

Comments
 (0)