unslothai/unsloth · warning · ValueError

block_id is required when using file_ids

Error message

block_id is required when using file_ids

What it means

Pydantic model_validator error on SeedInspectUploadRequest when file_ids is used without block_id. Multi-file uploads are staged under a block (an upload grouping); the inspect endpoint needs the block id to resolve where the files live, unlike the legacy inline mode which carries its own content.

Source

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

    # Shared fields
    preview_size: int = Field(default = 10, ge = 1, le = 50)
    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

View on GitHub (pinned to 203007d190)

Solutions

  1. Capture the block id from the multi-file upload response and include it as 'block_id' in the inspect request.
  2. Verify the exact field name is snake_case 'block_id', not 'blockId'.
  3. Ensure block_id is a non-empty string after any trimming.

Example fix

// before
{ "file_ids": ["f1"], "file_names": ["a.jsonl"] }
// after
{ "file_ids": ["f1"], "file_names": ["a.jsonl"], "block_id": "blk-42" }
Defensive patterns

Strategy: validation

Validate before calling

def multi_file_fields_valid(file_ids: list[str] | None, block_id: str | None) -> bool:
    return file_ids is None or bool(block_id and block_id.strip())

Type guard

def has_block_id(p: dict) -> bool:
    bid = p.get("block_id")
    return isinstance(bid, str) and bid.strip() != ""

Prevention

When it happens

Trigger: POSTing {"file_ids": [...], "file_names": [...]} with no 'block_id' key (or block_id: null / empty string), after the files were uploaded through the multi-file block upload flow.

Common situations: Client forgets to thread the block id returned by the upload endpoint into the subsequent inspect call; partial refactor from the legacy single-file API; block id stored under a different key name (e.g. 'blockId') in the client.

Related errors


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