unslothai/unsloth · warning · ValueError

file_names must be provided and same length as file_ids

Error message

file_names must be provided and same length as file_ids

What it means

Pydantic model_validator error on SeedInspectUploadRequest when file_ids is used but file_names is missing or its length differs from file_ids. The inspect flow needs a name for each uploaded file (for format detection / display), and the arrays must stay index-aligned.

Source

Thrown at studio/backend/models/data_recipe.py:104

    seed_source_type: str | None = None
    unstructured_chunk_size: int | None = Field(default = None, ge = 1, le = 20000)
    unstructured_chunk_overlap: int | None = Field(default = None, ge = 0, le = 20000)

    @model_validator(mode = "after")
    def _check_mutual_exclusivity(self) -> "SeedInspectUploadRequest":
        has_legacy = self.content_base64 is not None
        has_multi = self.file_ids is not None
        if has_legacy and has_multi:
            raise ValueError("Provide either content_base64 or file_ids, not both")
        if not has_legacy and not has_multi:
            raise ValueError("Provide either content_base64 or file_ids")
        if has_multi:
            if len(self.file_ids) == 0:
                raise ValueError("file_ids must not be empty")
            if not self.block_id:
                raise ValueError("block_id is required when using file_ids")
            if self.file_names is None or len(self.file_ids) != len(self.file_names):
                raise ValueError("file_names must be provided and same length as file_ids")
        if has_legacy:
            if not self.filename:
                raise ValueError("filename is required when using content_base64")
        return self


class SeedInspectResponse(BaseModel):
    dataset_name: str
    resolved_path: str
    columns: list[str] = Field(default_factory = list)
    preview_rows: list[dict[str, Any]] = Field(default_factory = list)
    split: str | None = None
    subset: str | None = None
    resolved_paths: list[str] | None = None


class UnstructuredFileUploadResponse(BaseModel):
    file_id: str

View on GitHub (pinned to 203007d190)

Solutions

  1. Build both arrays from the same source of truth (iterate one selection list and emit {id, name} pairs).
  2. Add an assertion in the client before submit: fileIds.length === fileNames.length.
  3. If names are unknown, request them from the upload response rather than constructing them ad hoc.

Example fix

// before
{ "file_ids": ["f1", "f2"], "file_names": ["a.jsonl"], "block_id": "b" }
// after
{ "file_ids": ["f1", "f2"], "file_names": ["a.jsonl", "b.jsonl"], "block_id": "b" }
Defensive patterns

Strategy: validation

Validate before calling

def id_name_arrays_aligned(file_ids: list[str], file_names: list[str] | None) -> bool:
    return file_names is not None and len(file_ids) == len(file_names)

Type guard

def is_aligned_upload(ids: list[str], names: list[str] | None) -> bool:
    return isinstance(names, list) and len(ids) == len(names)

Prevention

When it happens

Trigger: POSTing file_ids of length 3 with file_ids.length != file_names.length — e.g. omitting file_names entirely, sending 2 names for 3 ids, or appending an id without appending its name after a race in the UI selection state.

Common situations: Client state desync when files are added/removed concurrently; partial array updates in reducers; a rename feature that pushes to one array but not the other.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/bdcdef889e5037ef. Report an issue: GitHub.