{"record":{"id":"8cf42ddb38fa656a","repo":"microsoft/qlib","slug":"invalid-mount-path","errorCode":null,"errorMessage":"Invalid mount path","messagePattern":"Invalid mount path","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"qlib/__init__.py","lineNumber":123,"sourceCode":"        sys_type = platform.system()\n        if \"windows\" in sys_type.lower():\n            # system: window\n            try:\n                subprocess.run(\n                    [\"mount\", \"-o\", \"anon\", provider_uri, mount_path],\n                    capture_output=True,\n                    text=True,\n                    check=True,\n                )\n                LOG.info(\"Mount finished.\")\n            except subprocess.CalledProcessError as e:\n                error_output = (e.stdout or \"\") + (e.stderr or \"\")\n                if e.returncode == 85:\n                    LOG.warning(f\"{provider_uri} already mounted at {mount_path}\")\n                elif e.returncode == 53:\n                    raise OSError(\"Network path not found\") from e\n                elif \"error\" in error_output.lower() or \"错误\" in error_output:\n                    raise OSError(\"Invalid mount path\") from e\n                else:\n                    raise OSError(f\"Unknown mount error: {error_output.strip()}\") from e\n        else:\n            # system: linux/Unix/Mac\n            # check mount\n            _remote_uri = provider_uri[:-1] if provider_uri.endswith(\"/\") else provider_uri\n            # `mount a /b/c` is different from `mount a /b/c/`. So we convert it into string to make sure handling it accurately\n            mount_path = str(mount_path)\n            _mount_path = mount_path[:-1] if mount_path.endswith(\"/\") else mount_path\n            _check_level_num = 2\n            _is_mount = False\n            while _check_level_num:\n                with subprocess.Popen(\n                    [\"mount\"],\n                    text=True,\n                    stdout=subprocess.PIPE,\n                    stderr=subprocess.STDOUT,\n                ) as shell_r:","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/__init__.py#L105-L141","documentation":"MemCache.__getitem__ (qlib/data/cache.py:173) is a dispatcher: the key must be one of three single-letter strings — 'c' (calendar cache), 'i' (instrument cache), 'f' (feature cache). Any other key raises KeyError('Unknown memcache unit'). Code throughout qlib accesses the shared cache H as H[\"c\"], H[\"i\"], H[\"f\"], so this error means a caller used an undocumented key.","triggerScenarios":"Calling H[<key>] on the qlib mem-cache object qlib.data.cache.H with a key other than 'c', 'i', 'f' — e.g. H[\"calendar\"] or a variable that accidentally holds None/empty string; usually only hit by code touching qlib internals directly.","commonSituations":"Custom cache-aware providers or monkey-patches that assume a dict-like arbitrary-key cache; refactoring code where a key constant was renamed.","solutions":["Use one of the documented units: 'c' for calendar, 'i' for instrument, 'f' for feature series","If you need custom cached data, use your own dict/MemCache instance rather than overloading qlib's H","Check the variable holding the key is not None or '' from an upstream bug"],"exampleFix":"# before\ncal_cache = H[\"calendar\"]\n\n# after\nfrom qlib.data.cache import H\ncal_cache = H[\"c\"]","handlingStrategy":"type-guard","validationCode":"VALID_UNITS = {\"c\", \"i\", \"f\"}\n\ndef get_cache_unit(key: str):\n    assert key in VALID_UNITS, f\"memcache unit must be one of {VALID_UNITS}, got {key!r}\"\n    return H[key]","typeGuard":"def is_memcache_unit(key: str) -> bool:\n    return key in (\"c\", \"i\", \"f\")","tryCatchPattern":"try:\n    unit = H[key]\nexcept KeyError as e:\n    if \"Unknown memcache unit\" in str(e):\n        # fall back to explicit unit selection\n        unit = {\"calendar\": \"c\", \"instrument\": \"i\", \"feature\": \"f\"}[key]\n    else:\n        raise","preventionTips":["Treat qlib.data.cache.H as internal API; prefer public providers","Centralize cache-unit keys as module constants ('c'/'i'/'f')","Do not store custom data in qlib's shared mem cache"],"tags":["qlib","cache","internal-api","key-error"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}