Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Repocard] Respect configured endpoint when validating cards
  • Loading branch information
Wauplin committed Oct 2, 2026
commit fe9fc2996378e56ce5977a8c3e1112ce6d94d858
2 changes: 1 addition & 1 deletion src/huggingface_hub/repocard.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def validate(self, repo_type: str | None = None):
headers = {"Accept": "text/plain"}

try:
response = get_session().post("https://huggingface.co/api/validate-yaml", json=body, headers=headers)
response = get_session().post(f"{constants.ENDPOINT}/api/validate-yaml", json=body, headers=headers)
hf_raise_for_status(response)
except HfHubHTTPError as exc:
if response.status_code == 400:
Expand Down
17 changes: 17 additions & 0 deletions tests/test_repocard.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import re
import time
from pathlib import Path
from unittest.mock import Mock

import httpx2
import pytest
import yaml

Expand Down Expand Up @@ -637,6 +639,21 @@ def test_validate_repocard(self):
with pytest.raises(ValueError, match='- Error: "license" must be one of'):
card.validate()

def test_validate_repocard_uses_configured_endpoint(self, monkeypatch):
endpoint = "https://private-hub.example.com"
monkeypatch.setattr(constants, "ENDPOINT", endpoint)
post = Mock(return_value=httpx2.Response(200, request=httpx2.Request("POST", f"{endpoint}/api/validate-yaml")))
monkeypatch.setattr("huggingface_hub.repocard.get_session", Mock(return_value=Mock(post=post)))

card = RepoCard(DUMMY_MODELCARD)
card.validate()

post.assert_called_once_with(
f"{endpoint}/api/validate-yaml",
json={"repoType": "model", "content": str(card)},
headers={"Accept": "text/plain"},
)

def test_push_to_hub(self, api: HfApi, repo_factory: RepoFactory):
repo_id = repo_factory(repo_id=repo_name("push-card")).repo_id

Expand Down
Loading