Skip to content

[Python] Fix Hugging Face API error and token handling - #40779

Draft
bvolpato wants to merge 1 commit into
apache:masterfrom
bvolpato:bvolpato/huggingface-api-error-reporting
Draft

bvolpato wants to merge 1 commit into
apache:masterfrom
bvolpato:bvolpato/huggingface-api-error-reporting

Conversation

@bvolpato

Copy link
Copy Markdown
Contributor

Related #30799.

Raise HTTP errors before decoding Hugging Face responses as embeddings, so a failed request reports its status and endpoint instead of failing later in NumPy.

Reuse the authorization established when loading the session. The redundant request header currently replaces a valid HF_TOKEN fallback with Bearer None.

Regression checks fail before the fix and pass afterward using real prepared requests and response objects. The local module tests, Ruff, and YAPF pass. The provider rejection seen in CI still needs separate diagnosis.

@github-actions github-actions Bot added python size/s S: 10-49 lines changed labels Oct 25, 2026
@codecov

codecov Bot commented Oct 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.93%. Comparing base (a8d6afd) to head (a82805d).
⚠️ Report is 74 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40779      +/-   ##
==========================================
- Coverage   80.04%   79.93%   -0.12%     
==========================================
  Files         490      493       +3     
  Lines       82916    83474     +558     
==========================================
+ Hits        66373    66721     +348     
- Misses      16543    16753     +210     
Flag Coverage Δ
python 79.93% <100.00%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python size/s S: 10-49 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant