{"record":{"id":"56f241d1aa3ff00c","repo":"unslothai/unsloth","slug":"dataset-cleaned-not-found","errorCode":null,"errorMessage":"Dataset '{cleaned}' not found.","messagePattern":"Dataset '(.+?)' not found\\.","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"studio/backend/routes/training.py","lineNumber":3621,"sourceCode":"_MAX_CAPTION_CHARS = 2000\n\n\ndef _resolve_dataset_folder(name: str, *, must_exist: bool = True) -> Path:\n    \"\"\"Validate ``name`` (single component, no traversal) and resolve it under the Studio\n    datasets root. 404 when a read target is missing.\"\"\"\n    from utils.paths import datasets_root\n\n    cleaned = _clean_diffusion_dataset_name(name)\n    root = datasets_root().resolve()\n    folder = root / cleaned\n    # Reject a symlinked dataset directory and prove the resolved folder stays under root: _safe_dataset_image_path only checks each image path, not the folder.\n    if folder.is_symlink():\n        raise HTTPException(\n            status_code = 400,\n            detail = f\"Dataset '{cleaned}' must not be a symbolic link.\",\n        )\n    if must_exist and not folder.is_dir():\n        raise HTTPException(status_code = 404, detail = f\"Dataset '{cleaned}' not found.\")\n    try:\n        folder.resolve(strict = must_exist).relative_to(root)\n    except (OSError, ValueError):\n        raise HTTPException(\n            status_code = 400,\n            detail = f\"Dataset '{cleaned}' escapes the Studio datasets directory.\",\n        )\n    return folder\n\n\n# Match diffusion's 4096px decoded-image limit.\n_MAX_TRAINING_IMAGE_SIDE = 4096\n\n\ndef _validate_uploaded_training_image(path: Path, original_name: str) -> None:\n    \"\"\"Reject an uploaded training image whose decoded dimensions exceed the per-side limit.\n\n    Reads only the header (never img.load()), so a small-payload / huge-dimension file is caught","sourceCodeStart":3603,"sourceCodeEnd":3639,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/training.py#L3603-L3639","documentation":"HTTP 404 from _resolve_dataset_folder when must_exist=True and the cleaned dataset name does not exist as a directory under the Studio datasets root. The name was syntactically valid (passed _clean_diffusion_dataset_name); the folder simply is not there — deleted, never created, or created under a different name.","triggerScenarios":"Any dataset read route (list images, serve image, update caption, delete image, dataset summary) with a name that has no matching directory. Typical: GET /training/diffusion/dataset/old-name/image/cat.png after the dataset was deleted or renamed, or a stale UI tab holding an old dataset ID.","commonSituations":"Dataset deleted in another browser tab while a labeling grid stayed open; renaming a dataset out-of-band (shell mv) so the old name 404s; fresh installs referencing a dataset that was never imported; typos in scripted API calls.","solutions":["Reload the dataset list (GET /diffusion/datasets) and use a current name.","If the dataset was renamed on disk, rename it back or re-create it via upload/import and update your references.","If it was deleted, re-import the example dataset or re-upload the files."],"exampleFix":"// before\nawait api.get(`/training/diffusion/dataset/${name}/images`);\n\n// after\nconst datasets = await api.get('/training/diffusion/datasets');\nif (!datasets.some(d => d.name === name)) throw new Error(`Dataset '${name}' gone; refresh list`);\nawait api.get(`/training/diffusion/dataset/${name}/images`);","handlingStrategy":"validation","validationCode":"from utils.paths import datasets_root\n\ndef dataset_exists(name: str) -> bool:\n    folder = datasets_root() / name\n    return folder.is_dir() and not folder.is_symlink()","typeGuard":"def is_dataset_not_found(exc: HTTPException) -> bool:\n    return exc.status_code == 404 and 'not found' in (exc.detail or '')","tryCatchPattern":"try:\n    folder = _resolve_dataset_folder(name, must_exist=True)\nexcept HTTPException as e:\n    if e.status_code == 404:\n        return RefreshDatasetList()  # recover by re-enumerating\n    raise","preventionTips":["Refresh the dataset list before operating on a dataset selected long ago.","Handle concurrent deletion: two tabs, one deletes — the other must re-fetch.","Avoid renaming dataset directories outside the Studio UI."],"tags":["http-404","fastapi","dataset","not-found"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}