{"record":{"id":"829f4650b0906d45","repo":"unslothai/unsloth","slug":"file-ids-must-not-be-empty","errorCode":null,"errorMessage":"file_ids must not be empty","messagePattern":"file_ids must not be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"studio/backend/models/data_recipe.py","lineNumber":100,"sourceCode":"    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)\n    split: str | None = None\n    subset: str | None = None\n    resolved_paths: list[str] | None = None","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/models/data_recipe.py#L82-L118","documentation":"Pydantic model_validator error on SeedInspectUploadRequest when the multi-file mode is selected (file_ids present) but the list is empty. An empty upload has nothing to inspect, and distinguishing it here yields a clearer 422 than a downstream 'no files resolved' failure.","triggerScenarios":"POSTing {\"file_ids\": [], ...} — typically a client that initializes an empty selection array and submits before any files are picked, or a filter that removes all ids.","commonSituations":"UI allowing submit with zero selected files; a dedupe/filter step that empties the array; state reset bugs that clear the list but not the submit flag.","solutions":["Ensure file_ids contains at least one previously uploaded file id before calling the endpoint.","Disable the submit action in the UI until the selection is non-empty.","If the array is built dynamically, log its length right before the request to catch filter bugs."],"exampleFix":"// before\n{ \"file_ids\": [], \"file_names\": [], \"block_id\": \"b1\" }\n// after\n{ \"file_ids\": [\"file-123\"], \"file_names\": [\"a.jsonl\"], \"block_id\": \"b1\" }","handlingStrategy":"validation","validationCode":"def file_ids_valid(file_ids: list[str] | None) -> bool:\n    return file_ids is None or len(file_ids) > 0","typeGuard":"def is_nonempty_id_list(v: list[str] | None) -> bool:\n    return v is None or (isinstance(v, list) and len(v) > 0)","tryCatchPattern":null,"preventionTips":["Guard the submit handler: if not fileIds.length, disable the button.","After filtering/dedupe steps, assert the array is still non-empty.","Log array length immediately before the request to catch state bugs."],"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"}