{"record":{"id":"98cd0e9428742aed","repo":"unslothai/unsloth","slug":"invalid-transport-mode-mode-r-transports-sor","errorCode":null,"errorMessage":"Invalid transport mode: {mode!r} (transports: {sorted(VALID_TRANSPORTS)}, request modes: {sorted(VALID_TRANSPORT_MODES)})","messagePattern":"Invalid transport mode: (.+?) \\(transports: (.+?), request modes: (.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/hub/utils/download_registry.py","lineNumber":776,"sourceCode":"    ``protected_blob_hashes`` are blobs a concurrent same-repo peer is writing;\n    they are excluded from every purge so a shared companion is never deleted\n    mid-write.\n\n    Scope: ``root`` selects the cache captured by the caller. It defaults to the\n    active ``HF_HUB_CACHE`` root for workers that inherit their cache through\n    the environment. Markers are written for the new mode before returning,\n    except when an HTTP purge cannot remove every selected partial. Withholding\n    the marker keeps the surviving partial untrusted.\n    \"\"\"\n    if mode not in VALID_TRANSPORTS:\n        if mode == TRANSPORT_AUTO:\n            # \"auto\" is a request preference, not a cache writer: it must be resolved to xet/http\n            # before reaching this layer. Naming it turns \"invalid transport\" into the actual bug.\n            raise ValueError(\n                f\"{TRANSPORT_AUTO!r} must be resolved to a concrete transport before preparing the \"\n                f\"cache; expected one of {sorted(VALID_TRANSPORTS)}\"\n            )\n        raise ValueError(\n            f\"Invalid transport mode: {mode!r} (transports: {sorted(VALID_TRANSPORTS)}, \"\n            f\"request modes: {sorted(VALID_TRANSPORT_MODES)})\"\n        )\n    root = hf_cache_root(create = True) if root is None else hf_cache_root(create = True, root = root)\n    if root is None:\n        return 0\n    target = target_dir_name(repo_type, repo_id)\n    try:\n        entries = [e for e in root.iterdir() if e.name.lower() == target]\n    except OSError:\n        return 0\n    if not entries:\n        # First download: pre-create the repo dir so the marker lands before the\n        # worker writes any bytes. Otherwise a SIGKILL mid-download leaves a\n        # partial with no marker that the resume then purges.\n        canonical = repo_cache_dir_name(repo_type, repo_id)\n        new_entry = root / canonical\n        try:","sourceCodeStart":758,"sourceCodeEnd":794,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/hub/utils/download_registry.py#L758-L794","documentation":"Raised by download_registry's cache-preparation layer when `mode` is not one of VALID_TRANSPORTS ({'http','xet'}). Request modes also permit 'auto', but 'auto' must be resolved to a concrete transport before reaching this layer and gets a dedicated error. The message lists both the valid cache transports and the valid request modes to make the mismatch obvious.","triggerScenarios":"Calling prepare/purge cache APIs with mode='auto' handled elsewhere, but mode='asyncio', 'hf_transfer', a typo like 'Xet' (case-sensitive), or None reaches this function directly instead of via the request-mode resolution path.","commonSituations":"New code paths (workers, CLI scripts) built directly on the cache layer and skipping transport resolution; config files carrying a stale or misspelled transport value after an upgrade that split request modes from cache transports.","solutions":["Resolve 'auto' to 'http' or 'xet' before calling the cache layer (use the existing resolver used by the download request path).","Pass exactly 'http' or 'xet' (lowercase) — the set is case-sensitive.","Validate config early: reject any transport not in {'http','xet','auto'} at settings-load time with a clear message."],"exampleFix":"# before\nprepare_cache_for_download(repo, mode='auto')\n# after\nmode = resolve_transport('auto')  # -> 'xet' or 'http'\nprepare_cache_for_download(repo, mode=mode)","handlingStrategy":"type-guard","validationCode":"VALID_TRANSPORTS = {\"http\", \"xet\"}\nREQUEST_MODES = {\"http\", \"xet\", \"auto\"}\n\ndef assert_transport(mode: str) -> str:\n    if mode == \"auto\":\n        return resolve_auto_transport()  # existing resolver -> 'http' | 'xet'\n    if mode not in VALID_TRANSPORTS:\n        raise ValueError(f\"transport must be one of {sorted(VALID_TRANSPORTS)}, got {mode!r}\")\n    return mode","typeGuard":"from typing import Literal\nTransport = Literal['http', 'xet']\nRequestMode = Literal['http', 'xet', 'auto']\n\ndef is_transport(mode: str) -> bool:\n    return mode in ('http', 'xet')","tryCatchPattern":null,"preventionTips":["Type transport config as Literal['http','xet'] (request layer may add 'auto') so typos fail at typecheck time.","Never pass request modes straight to cache-layer APIs; resolve 'auto' first.","Transport names are case-sensitive and lowercase."],"tags":["validation","hf-download","transport","configuration"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}