unslothai/unsloth · error · ValueError
subset is too long (max {MAX_HF_DATASET_OPTION_LENGTH} chars
Error message
subset is too long (max {MAX_HF_DATASET_OPTION_LENGTH} chars) What it means
Raised by the _check_subset field validator on TrainingStartRequest: the optional dataset subset/config name is capped at MAX_HF_DATASET_OPTION_LENGTH characters after trimming (empty-after-trim normalizes to None). Subsets are short identifiers like 'default' or 'plain_text', so an over-long value signals a pasted blob or wrong field mapping. It fires before the character-validity check.
Source
Thrown at studio/backend/models/training.py:249
return None
if len(v) > 256:
raise ValueError("hf_dataset is too long (max 256 chars)")
if ".." in v:
raise ValueError("hf_dataset must not contain '..'")
if any(_HF_DATASET_ID_SEGMENT_RE.fullmatch(segment) is None for segment in v.split("/")):
raise ValueError("hf_dataset contains invalid characters or path segments")
return v
@field_validator("subset")
@classmethod
def _check_subset(cls, v: Optional[str]) -> Optional[str]:
if v is None:
return v
v = v.strip()
if not v:
return None
if len(v) > MAX_HF_DATASET_OPTION_LENGTH:
raise ValueError(f"subset is too long (max {MAX_HF_DATASET_OPTION_LENGTH} chars)")
if not valid_hf_dataset_config_name(v):
raise ValueError("subset contains invalid characters")
return v
@field_validator(
"model_local_path",
"dataset_local_path",
"model_snapshot_path",
"dataset_snapshot_path",
)
@classmethod
def _check_cache_local_path(cls, v: Optional[str]) -> Optional[str]:
if v is None:
return v
v = v.strip()
if not v:
return None
if len(v) > 4096:View on GitHub (pinned to 203007d190)
Solutions
- Send the short subset/config name only, e.g. 'default'.
- Check your request mapping: long config blobs belong elsewhere, not in subset.
- Omit subset entirely (it normalizes to None) if the dataset has a single config.
Example fix
// before
{ hf_dataset: "user/data", subset: JSON.stringify(config) }
// after
{ hf_dataset: "user/data", subset: "default" } Defensive patterns
Strategy: validation
Validate before calling
def subset_short_enough(body: dict, max_len: int) -> bool:
v = (body.get("subset") or "").strip()
return len(v) <= max_len Type guard
function subsetOk(subset: string | undefined, maxLen: number): boolean {
return (subset?.trim().length ?? 0) <= maxLen;
} Prevention
- Use a short text input for subset, not a text area
- Fetch the dataset's real config list from the HF API and use a dropdown
When it happens
Trigger: POST a training start request with a subset string longer than the configured max (MAX_HF_DATASET_OPTION_LENGTH), e.g. a full config JSON accidentally placed in subset.
Common situations: Mapping the wrong config field (e.g. training args JSON) into subset; pasting a dataset README; a UI text-area instead of a short input bound to subset.
Related errors
- hf_dataset is too long (max 256 chars)
- hf_dataset contains invalid characters or path segments
- subset contains invalid characters
- dataset_slice_end must be greater than or equal to dataset_s
- split name is too long (max {MAX_HF_DATASET_OPTION_LENGTH} c
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/95a054e3112fc2f1.
Report an issue: GitHub.