Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: return 400 for a rejected dataset path in check-format (#7842)
Daniel Han2cdd03230387
diff --git a/studio/backend/routes/datasets.py b/studio/backend/routes/datasets.pyindex 195165e8a1f..5e25f54d026 100644--- a/studio/backend/routes/datasets.py+++ b/studio/backend/routes/datasets.py@@ -535,7 +535,12 @@ def check_format(request: CheckFormatRequest, current_subject: str = Depends(getlogger.info(f"Checking format for dataset: {request.dataset_name}")- dataset_path = resolve_dataset_path(request.dataset_name)+ try:+ dataset_path = resolve_dataset_path(request.dataset_name)+ except ValueError as e:+ # Malformed path (null bytes, '..', outside roots) is a client error:+ # surface 400 rather than the generic 500 below.+ raise HTTPException(status_code = 400, detail = str(e)) from etotal_rows = None# Uploads and recipes always arrive as absolute paths, so a missing one is adiff --git a/studio/backend/tests/test_dataset_check_format_missing.py b/studio/backend/tests/test_dataset_check_format_missing.pyindex 86257de8d2c..380de9557db 100644--- a/studio/backend/tests/test_dataset_check_format_missing.py+++ b/studio/backend/tests/test_dataset_check_format_missing.py@@ -117,3 +117,30 @@ def test_hub_repo_id_never_reports_a_deleted_file(no_hub):assert error.status_code != 404assert no_hub, "the Hub branch is where a relative reference belongs"+++ ("dataset_name", "expected"),+ [+ pytest.param("{anchor}not-a-dataset.jsonl", "under a dataset root", id = "outside-roots"),+ pytest.param("{uploads}/../escape.jsonl", "'..' segments", id = "traversal"),+ pytest.param("uploads/nul\x00byte.jsonl", "null bytes", id = "null-byte"),+ ],+)+def test_rejected_paths_are_client_errors(dataset_name, expected, isolated_studio_home, no_hub):+ """A path resolve_dataset_path refuses is the caller's mistake, not a server+ fault, and must never reach the Hub. Matches the hub check-format twin."""+ from utils.paths import dataset_uploads_root++ # Anchor of the studio home: absolute on POSIX ("/x") and Windows ("C:\\x").+ # A hardcoded "/etc/x" is relative on Windows and misses the branch entirely.+ error = _check(+ dataset_name.format(+ anchor = isolated_studio_home.anchor,+ uploads = dataset_uploads_root(),+ )+ )++ assert error.status_code == 400+ assert expected in str(error.detail)+ assert no_hub == []