{"record":{"id":"ab0a296c1e893a39","repo":"unslothai/unsloth","slug":"provide-either-content-base64-or-file-ids","errorCode":null,"errorMessage":"Provide either content_base64 or file_ids","messagePattern":"Provide either content_base64 or file_ids","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"studio/backend/models/data_recipe.py","lineNumber":97,"sourceCode":"    content_base64: str | None = None\n    # Multi-file flow (mutually exclusive with content_base64)\n    block_id: str | None = None\n    file_ids: list[str] | None = None\n    file_names: list[str] | None = None\n    # Shared fields\n    preview_size: int = Field(default = 10, ge = 1, le = 50)\n    seed_source_type: str | None = None\n    unstructured_chunk_size: int | None = Field(default = None, ge = 1, le = 20000)\n    unstructured_chunk_overlap: int | None = Field(default = None, ge = 0, le = 20000)\n\n    @model_validator(mode = \"after\")\n    def _check_mutual_exclusivity(self) -> \"SeedInspectUploadRequest\":\n        has_legacy = self.content_base64 is not None\n        has_multi = self.file_ids is not None\n        if has_legacy and has_multi:\n            raise ValueError(\"Provide either content_base64 or file_ids, not both\")\n        if not has_legacy and not has_multi:\n            raise ValueError(\"Provide either content_base64 or file_ids\")\n        if has_multi:\n            if len(self.file_ids) == 0:\n                raise ValueError(\"file_ids must not be empty\")\n            if not self.block_id:\n                raise ValueError(\"block_id is required when using file_ids\")\n            if self.file_names is None or len(self.file_ids) != len(self.file_names):\n                raise ValueError(\"file_names must be provided and same length as file_ids\")\n        if has_legacy:\n            if not self.filename:\n                raise ValueError(\"filename is required when using content_base64\")\n        return self\n\n\nclass SeedInspectResponse(BaseModel):\n    dataset_name: str\n    resolved_path: str\n    columns: list[str] = Field(default_factory = list)\n    preview_rows: list[dict[str, Any]] = Field(default_factory = list)","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/models/data_recipe.py#L79-L115","documentation":"Pydantic model_validator error on SeedInspectUploadRequest when neither content_base64 nor file_ids is present — the request supplies no data to inspect at all. Exactly one of the two upload modes must be chosen.","triggerScenarios":"POSTing to the seed-inspect endpoint with neither 'content_base64' nor 'file_ids' in the JSON body, e.g. only optional fields like preview_size/seed_source_type, or a client bug that skips the payload entirely.","commonSituations":"Frontend form submitted before a file is chosen; serialization bug that drops the data field (e.g. wrong key casing: Content_Base64); API exploration with an empty body.","solutions":["Include exactly one of content_base64 (with filename) or file_ids (with file_names and block_id) in the request.","Check for key-casing mismatches — the fields are lowercase snake_case.","Add a client-side check that the upload form has data before submitting."],"exampleFix":"// before\n{ \"preview_size\": 10 }\n// after\n{ \"content_base64\": \"...\", \"filename\": \"a.jsonl\", \"preview_size\": 10 }","handlingStrategy":"validation","validationCode":"def has_seed_data(payload: dict) -> bool:\n    return payload.get(\"content_base64\") is not None or payload.get(\"file_ids\") is not None","typeGuard":"def is_seed_inspect_payload(p: dict) -> bool:\n    return (\"content_base64\" in p) != (\"file_ids\" in p) and (\"content_base64\" in p or \"file_ids\" in p)","tryCatchPattern":null,"preventionTips":["Disable submit until the user has selected or uploaded at least one file.","Use exact snake_case keys; log the outgoing payload keys during debugging.","Write a client-side mirror of the validator so errors surface in the UI, not as 422s."],"tags":["validation","pydantic","api","http-422","upload"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}