Skip to content

fix(studio/hub): apply repo_id length limit per segment, not whole string (#6946) - #6953

Merged
Etherll merged 4 commits into
unslothai:mainfrom
Anai-Guo:fix-repo-id-length-6946
Jul 8, 2026
Merged

Etherll merged 4 commits into
unslothai:mainfrom
Anai-Guo:fix-repo-id-length-6946

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What

is_valid_repo_id() in studio/backend/hub/utils/paths.py applied the 96-character limit to the entire namespace/repo_name string:

if len(repo_id) > _MAX_REPO_ID_LENGTH or repo_id.endswith(".git"):
    return False

This falsely rejects repos whose name segment is within the 96-char limit but whose combined namespace/repo_name exceeds 96 chars. HuggingFace Hub's own huggingface_hub.validate_repo_id (regex ^(\b[\w\-.]+\b/)?\b[\w\-.]{1,96}\b$) caps the repo-name segment, not the whole string, so such repos load fine directly via huggingface_hub but are blocked in Studio.

Example from the issue — 100 chars total, name segment 92 chars (valid):

DavidAU/Qwen3.6-40B-Claude-4.6-Opus-Deckard-Heretic-Uncensored-Thinking-NEO-CODE-Di-IMatrix-MAX-GGUF

Fix

Move the length check inside the per-segment validation (alongside the existing regex and reserved-name checks), so the 96-char limit is applied to each segment rather than the full string. Minimal, behavior-preserving for every previously-valid id.

Verification

  • Reported 100-char id (92-char name) → now accepted.
  • Name segment of 97+ chars → still rejected (regression guard).
  • Normal ids (meta-llama/Llama-3-8B, gpt2), .git suffix, and 3-segment ids behave unchanged.

Fixes #6946

🤖 Generated with Claude Code

…ring

is_valid_repo_id() applied the 96-char limit to the full "namespace/repo_name"
string, so a repo with a valid (<=96 char) name but a long combined id was
falsely rejected. Match huggingface_hub.validate_repo_id by checking the length
per segment instead. Fixes unslothai#6946.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c245dbba46

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread studio/backend/hub/utils/paths.py Resolved
@Etherll Etherll self-assigned this Jul 8, 2026
@Etherll

Etherll commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 730001b8e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Etherll Etherll left a comment

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.

LGTM!

@Etherll
Etherll merged commit d0c8d55 into unslothai:main Jul 8, 2026
31 of 34 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e12062058

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if _state_filename_fits(longest_variant_key):
return base
digest = hashlib.sha256(base.encode("utf-8")).hexdigest()[:32]
return f"{repo_type}s--sha256-{digest}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep hashed state keys out of the raw repo namespace

When a newly accepted long repo ID is hashed here, the resulting key can collide with a legitimate short repo ID named sha256-<same 32 hex chars>: repo_cache_basename("model", "sha256-...") also produces models--sha256-.... In that scenario, cancelling, scanning, or deleting either repo reads or removes the other's manifest/marker through manifest_path, marker_path, and the variant iterators, which can misreport partial downloads or purge the wrong state. Use a hash prefix that raw repo IDs cannot generate, such as one containing an impossible --- separator, or escape raw keys before adding the hash namespace.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid repo_id: Studio rejects valid HF repo with 100-char namespace/repo_name (96-char limit applied to full string instead of name segment)

2 participants