{"record":{"id":"bdcdef889e5037ef","repo":"unslothai/unsloth","slug":"file-names-must-be-provided-and-same-length-as-fil","errorCode":null,"errorMessage":"file_names must be provided and same length as file_ids","messagePattern":"file_names must be provided and same length as file_ids","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"studio/backend/models/data_recipe.py","lineNumber":104,"sourceCode":"    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\n\n\nclass UnstructuredFileUploadResponse(BaseModel):\n    file_id: str","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/models/data_recipe.py#L86-L122","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Build both arrays from the same source of truth (iterate one selection list and emit {id, name} pairs).","Add an assertion in the client before submit: fileIds.length === fileNames.length.","If names are unknown, request them from the upload response rather than constructing them ad hoc."],"exampleFix":"// before\n{ \"file_ids\": [\"f1\", \"f2\"], \"file_names\": [\"a.jsonl\"], \"block_id\": \"b\" }\n// after\n{ \"file_ids\": [\"f1\", \"f2\"], \"file_names\": [\"a.jsonl\", \"b.jsonl\"], \"block_id\": \"b\" }","handlingStrategy":"validation","validationCode":"def id_name_arrays_aligned(file_ids: list[str], file_names: list[str] | None) -> bool:\n    return file_names is not None and len(file_ids) == len(file_names)","typeGuard":"def is_aligned_upload(ids: list[str], names: list[str] | None) -> bool:\n    return isinstance(names, list) and len(ids) == len(names)","tryCatchPattern":null,"preventionTips":["Generate both arrays in one loop over a single selection list of {id, name} pairs.","Assert fileIds.length === fileNames.length before submit.","Never append to one array without the other."],"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"}