Skip to content

[PM Fixer] Fix huggingface 1.29.0 compatibility: swallow HfUriError from commitUrl parsing - #548

Open
agrasth wants to merge 2 commits into
mainfrom
RTECO-1443556-fix-huggingface-1.29.0-compat
Open

[PM Fixer] Fix huggingface 1.29.0 compatibility: swallow HfUriError from commitUrl parsing#548
agrasth wants to merge 2 commits into
mainfrom
RTECO-1443556-fix-huggingface-1.29.0-compat

Conversation

@agrasth

@agrasth agrasth commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

upload_folder in huggingface_hub ≥ 1.20.0 fails against Artifactory with HfUriError (introduced in huggingface/huggingface_hub#4324). That PR changed RepoUrl to use the strict parse_hf_uri internally when processing the commit response. Artifactory returns a placeholder commitUrl that does not conform to the hf:// URI format the new parser expects. The actual upload to Artifactory completes successfully before the response is parsed — only the post-upload parsing step raises the error, causing all tests that call uploadTestModelToLocalRepo (and TestHuggingFaceUploadWithLocalGitVcsProps) to fail with require.NoError.

Fix

Modified huggingface_upload.py (embedded Python helper for jf hf u) to catch HfUriError from huggingface_hub.errors specifically and return silently, treating the upload as successful. All other exceptions are still propagated.

This is a Python-script-only fix — no Go source files were modified and no exported symbols changed.

Backward compatibility:

  • huggingface_hub < 1.20.0: HfUriError does not exist; the except ImportError branch is taken, behavior unchanged.
  • huggingface_hub ≥ 1.20.0: HfUriError raised during post-upload response parsing is swallowed; HTTP errors, auth failures, and all other exceptions are still propagated.

Compatibility impact

No exported Go symbol was added, removed, or renamed. No go.mod or go.sum touched. Existing supported versions (pinned at 1.19.0) are unaffected since HfUriError did not exist before 1.20.0.

Test plan

  • go build ./... — no Go source files changed; cannot regress.
  • gofmt -l . — no Go files touched.
  • go vet ./... — same.
  • TestExtractPythonScripts (unit test): verifies scripts are extracted; content checking is not in scope.
  • Live PM integration test with huggingface_hub 1.29.0 against Artifactory could not be run in this environment (no live Artifactory). The fix targets the exact failure documented in .github/workflows/huggingfaceTests.yml lines 69-72.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Hugging Face uploads by gracefully handling compatibility-related errors reported after files are committed.
    • Added diagnostic details for handled upload errors to help with troubleshooting.
    • Other upload failures continue to be reported normally.

Opened automatically by PM Compat Fixer investigating huggingface 1.29.0.

…rl parsing

huggingface_hub >= 1.20.0 changed RepoUrl to use parse_hf_uri internally
(PR huggingface/huggingface_hub#4324), which strictly validates the commitUrl
field in the upload commit response. Artifactory returns a placeholder
commitUrl that does not conform to the hf:// URI format expected by the
new parser, causing upload_folder to raise HfUriError after the files have
already been committed to Artifactory.

Catch HfUriError specifically in the upload helper and treat it as a
non-fatal success: the upload completed before the response was parsed.
Versions of huggingface_hub < 1.20.0 are unaffected (HfUriError does not
exist; ImportError is caught and the raise path is unchanged).

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


pm-compat-fixer seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 5445b684-8220-48b3-aaec-e6db2a576509

📥 Commits

Reviewing files that changed from the base of the PR and between 51109ad and 64c51f5.

📒 Files selected for processing (2)
  • artifactory/commands/huggingface/huggingface_upload.py
  • artifactory/commands/huggingface/test_huggingface_upload.py

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Walkthrough

Walkthrough

The Hugging Face upload command now handles HfUriError from HfApi.upload_folder without failing after files are committed. It logs diagnostic details to stderr, re-raises other exceptions, and tolerates unavailable error-class imports.

Changes

Hugging Face upload handling

Layer / File(s) Summary
Selective upload exception handling
artifactory/commands/huggingface/huggingface_upload.py, artifactory/commands/huggingface/test_huggingface_upload.py
The upload command logs swallowed HfUriError details to stderr and preserves successful returns. Tests verify that HfUriError is swallowed and unrelated ValueError exceptions propagate.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 64c51

Hugging Face uploads now tolerate the known post-commit URI parsing error and report it on stderr, while other upload failures still fail normally. The change is ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the Hugging Face compatibility fix and the targeted HfUriError handling change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch RTECO-1443556-fix-huggingface-1.29.0-compat

Comment @coderabbitai help to get the list of available commands.

@agrasth agrasth added the pm-compat-fixer Opened automatically by JFrog's PM Compat Fixer agent label Sep 2, 2026
@agrasth agrasth changed the title Fix huggingface 1.29.0 compatibility: swallow HfUriError from commitUrl parsing [PM Fixer] Fix huggingface 1.29.0 compatibility: swallow HfUriError from commitUrl parsing Sep 2, 2026
itsmeleela
itsmeleela previously approved these changes Sep 7, 2026
repo_type=repo_type,
**kwargs
)
except Exception as e:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swallowing based on exception type assumes HfUriError can only occur post-commit in this call path. Can we pin this to the known-affected version range, or at least log when we swallow it, so we're not silently masking a genuine failure if that assumption stops holding in a future huggingface_hub release?

@agrasth agrasth Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 64c51f5: now logs a clear message to stderr when the HfUriError swallow triggers (files were already uploaded, only the response URL failed to parse).
Printed to stderr specifically since the Go caller (huggingFaceUpload.go) already streams stderr through unmodified without touching the stdout JSON success/failure contract it parses — so this doesn't risk interfering with that. Didn't add version-pinning on top since the affected range is only knowable approximately and would need its own upkeep; the log line covers the "don't silently mask a future failure" concern more durably.

# Artifactory returns a placeholder commitUrl that fails this parser, but the
# files were already committed before the response is parsed. Swallow the URI
# parse error so callers treat the upload as successful.
try:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we already have tests that mocks upload_folder to raise HfUriError and asserts we return cleanly, plus one asserting a different exception still propagates? This is the core behavior change so I think fixer should consider adding unit tests for code changes

@agrasth agrasth Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 64c51f5: test_huggingface_upload.py with exactly the two cases you described — one mocking upload_folder to raise HfUriError and asserting upload() returns cleanly, one mocking a different exception and asserting it still propagates.

Addresses review feedback on #548:
- Log a clear stderr line when HfUriError is swallowed, so a future case
  where this assumption breaks (e.g. HfUriError raised somewhere other
  than commit-response parsing) leaves a trail instead of a silent
  false-positive success. Printed to stderr, which the Go caller already
  streams through unmodified - doesn't touch the stdout JSON contract the
  caller actually parses.
- Add unit tests: one asserting HfUriError is swallowed and upload()
  returns cleanly, one asserting other exceptions still propagate.
  huggingface_hub.errors.HfUriError doesn't exist in most currently
  installed huggingface_hub versions (it's a recent addition), so the
  test patches it in at the exact import path with create=True rather
  than depending on a specific installed version - verified this
  actually exercises the real isinstance() check in
  huggingface_upload.py, not a copy of the logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pm-compat-fixer Opened automatically by JFrog's PM Compat Fixer agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants