{"record":{"id":"a369b6090379fb94","repo":"unslothai/unsloth","slug":"file-ids-must-not-be-empty-a369b6","errorCode":null,"errorMessage":"file_ids must not be empty","messagePattern":"file_ids must not be empty","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"studio/backend/routes/data_recipe/seed.py","lineNumber":624,"sourceCode":"        shutil.rmtree(block_dir)\n    except OSError as exc:\n        raise log_and_http_error(\n            exc,\n            500,\n            \"failed to delete uploaded files\",\n            event = \"data_recipe.seed.unstructured_block_delete_failed\",\n            log = logger,\n        ) from exc\n    if block_dir.exists():\n        raise HTTPException(500, \"failed to delete uploaded files\")\n    return {\"status\": \"ok\", \"deleted\": True}\n\n\n@router.post(\"/seed/inspect-upload\", response_model = SeedInspectResponse)\ndef inspect_seed_upload(payload: SeedInspectUploadRequest) -> SeedInspectResponse:\n    if payload.file_ids is not None:\n        if len(payload.file_ids) == 0:\n            raise HTTPException(400, \"file_ids must not be empty\")\n        _validate_safe_id(payload.block_id, \"block_id\")\n        for fid in payload.file_ids:\n            _validate_safe_id(fid, \"file_id\")\n        preview_rows = _read_preview_rows_from_multi_files(\n            block_id = payload.block_id,\n            file_ids = payload.file_ids,\n            file_names = payload.file_names,\n            preview_size = payload.preview_size,\n            chunk_size = payload.unstructured_chunk_size,\n            chunk_overlap = payload.unstructured_chunk_overlap,\n        )\n        columns = [\"chunk_text\", \"source_file\"] if preview_rows else []\n        resolved_paths = [\n            str(UNSTRUCTURED_UPLOAD_ROOT / payload.block_id / f\"{fid}.extracted.txt\")\n            for fid in payload.file_ids\n        ]\n        return SeedInspectResponse(\n            dataset_name = \"unstructured_seed\",","sourceCodeStart":606,"sourceCodeEnd":642,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/data_recipe/seed.py#L606-L642","documentation":"HTTP 400 raised at the top of POST /seed/inspect-upload when payload.file_ids is present (not None) but is an empty list. The API treats an explicit empty list as a malformed request — omit the field entirely if there is nothing to inspect.","triggerScenarios":"POST /seed/inspect-upload with {\"file_ids\": [], ...}, typically because the frontend serialized an empty selection instead of leaving the field out or using the single-file local path.","commonSituations":"UI sends the multi-file branch unconditionally with whatever selection exists; empty selection submitted; default [] in a request-building function that never gets popped.","solutions":["Omit file_ids from the JSON body when no files are selected.","Client-side: skip the inspect call entirely when the selection is empty.","Type the request so file_ids is optional and only include it when len > 0."],"exampleFix":"# before\nbody = {'block_id': bid, 'file_ids': selected_ids}  # may be []\n\n# after\nbody = {'block_id': bid}\nif selected_ids:\n    body['file_ids'] = selected_ids","handlingStrategy":"validation","validationCode":"const body = { block_id: blockId, preview_size: n };\nif (fileIds.length > 0) body.file_ids = fileIds;\nif (fileNames?.length > 0) body.file_names = fileNames;\ninspectUpload(body);","typeGuard":"function hasInspectableFiles(ids?: string[]): ids is string[] {\n  return Array.isArray(ids) && ids.length > 0;\n}","tryCatchPattern":"On 400 'file_ids must not be empty', log a client bug (empty selection should never reach the wire), fix the request builder, and skip the call.","preventionTips":["Only include file_ids in the payload when the selection is non-empty.","Disable the preview/inspect button when no files are selected."],"tags":["validation","upload","http-400","empty-list"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}