unslothai/unsloth · warning · ValueError
Provide either content_base64 or file_ids, not both
Error message
Provide either content_base64 or file_ids, not both
What it means
Pydantic model_validator error on SeedInspectUploadRequest when the payload sets BOTH content_base64 (legacy single-file inline upload) and file_ids (multi-file upload). The two upload modes are mutually exclusive; the validator runs after field validation and rejects the request with a 422 before any handler logic executes.
Source
Thrown at studio/backend/models/data_recipe.py:95
# Legacy single-file flow (mutually exclusive with file_ids)
filename: str | None = None
content_base64: str | None = None
# Multi-file flow (mutually exclusive with content_base64)
block_id: str | None = None
file_ids: list[str] | None = None
file_names: list[str] | None = None
# 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: strView on GitHub (pinned to 203007d190)
Solutions
- Remove one of the two fields from the request body — send either {"content_base64": ..., "filename": ...} or {"file_ids": [...], "file_names": [...], "block_id": ...}.
- Update the client's request builder so the two modes are separate code paths that never merge payloads.
- Check the response's 422 detail to confirm which validator fired.
Example fix
// before
{
"content_base64": "...",
"filename": "a.jsonl",
"file_ids": ["f1"]
}
// after
{
"file_ids": ["f1"],
"file_names": ["a.jsonl"],
"block_id": "block-1"
} Defensive patterns
Strategy: validation
Validate before calling
def build_seed_inspect_body(content_base64=None, filename=None,
file_ids=None, file_names=None, block_id=None):
has_legacy = content_base64 is not None
has_multi = file_ids is not None
assert not (has_legacy and has_multi), "mutually exclusive upload modes"
assert has_legacy or has_multi, "one upload mode required"
return ({\"content_base64\": content_base64, \"filename\": filename}
if has_legacy
else {"file_ids": file_ids, "file_names": file_names, "block_id": block_id}) Type guard
def is_single_seed_payload(p: dict) -> bool:
return ("content_base64" in p) != ("file_ids" in p) Try / catch
try:
resp = client.post("/api/data/seed/inspect", json=payload)
except ValidationError: # httpx/pydantic client-side
raise
if resp.status_code == 422:
detail = resp.json()["detail"]
# surface msg to the upload UI instead of retrying blindly Prevention
- Model the two upload modes as separate types in the client; never merge their fields.
- Before submit, assert exactly one of content_base64 / file_ids is present.
- Surfacing the 422 detail string in the UI pinpoints which constraint failed.
When it happens
Trigger: POSTing to the seed-inspect endpoint with a JSON body containing both 'content_base64' and 'file_ids' keys, e.g. a client that added multi-file support while still sending the legacy inline field for backward compatibility.
Common situations: Frontend migration from single-file to multi-file upload where the old field is not removed; API clients written defensively that populate every optional field; contract tests that send all fields.
Related errors
- Provide either content_base64 or file_ids
- file_ids must not be empty
- block_id is required when using file_ids
- file_names must be provided and same length as file_ids
- filename is required when using content_base64
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/6d726e48e5fd25a1.
Report an issue: GitHub.