{"record":{"id":"605078211a753bc1","repo":"microsoft/qlib","slug":"provider-uri-cannot-be-none","errorCode":null,"errorMessage":"provider_uri cannot be None","messagePattern":"provider_uri cannot be None","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"qlib/config.py","lineNumber":364,"sourceCode":"        \"\"\"\n        Motivation:\n        - get the right path (e.g. data uri) for accessing data based on given information(e.g. provider_uri, mount_path and frequency)\n        - some helper functions to process uri.\n        \"\"\"\n\n        def __init__(self, provider_uri: Union[str, Path, dict], mount_path: Union[str, Path, dict]):\n            \"\"\"\n            The relation of `provider_uri` and `mount_path`\n            - `mount_path` is used only if provider_uri is an NFS path\n            - otherwise, provider_uri will be used for accessing data\n            \"\"\"\n            self.provider_uri = provider_uri\n            self.mount_path = mount_path\n\n        @staticmethod\n        def format_provider_uri(provider_uri: Union[str, dict, Path]) -> dict:\n            if provider_uri is None:\n                raise ValueError(\"provider_uri cannot be None\")\n            if isinstance(provider_uri, (str, dict, Path)):\n                if not isinstance(provider_uri, dict):\n                    provider_uri = {QlibConfig.DEFAULT_FREQ: provider_uri}\n            else:\n                raise TypeError(f\"provider_uri does not support {type(provider_uri)}\")\n            for freq, _uri in provider_uri.items():\n                if QlibConfig.DataPathManager.get_uri_type(_uri) == QlibConfig.LOCAL_URI:\n                    provider_uri[freq] = str(Path(_uri).expanduser().resolve())\n            return provider_uri\n\n        @staticmethod\n        def get_uri_type(uri: Union[str, Path]):\n            uri = uri if isinstance(uri, str) else str(uri.expanduser().resolve())\n            is_win = re.match(\"^[a-zA-Z]:.*\", uri) is not None  # such as 'C:\\\\data', 'D:'\n            # such as 'host:/data/'   (User may define short hostname by themselves or use localhost)\n            is_nfs_or_win = re.match(\"^[^/]+:.+\", uri) is not None\n\n            if is_nfs_or_win and not is_win:","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/config.py#L346-L382","documentation":"QlibConfig.DataPathManager.format_provider_uri in qlib/config.py normalizes the provider_uri argument into a {freq: uri} dict. None is explicitly rejected with ValueError because data access requires at least one concrete location. This typically surfaces when qlib.init is called with provider_uri=None (the default of a partially-filled config) or a nested call re-formats the uri.","triggerScenarios":"qlib.init(provider_uri=None) or omitting provider_uri while some code path still constructs DataPathManager; building QlibConfig programmatically and passing a None obtained from config.get('provider_uri').","commonSituations":"Config templating where provider_uri is conditionally set and resolves to None; refactoring that reads the key with .get() before validating presence; upgrading qlib versions where None was previously tolerated until data load time.","solutions":["Set a concrete provider_uri in qlib.init (e.g. '~/.qlib/qlib_data/cn_data').","Guard before init: if provider_uri from your own config is None, either fail fast with a clear message or substitute the default path.","For multi-frequency data pass a dict like {'day': uri_day, '1min': uri_min} — never None values."],"exampleFix":"# before\nqlib.init(provider_uri=cfg.get('provider_uri'))  # None if key absent\n# after\nqlib.init(provider_uri=cfg.get('provider_uri', '~/.qlib/qlib_data/cn_data'))","handlingStrategy":"validation","validationCode":"if provider_uri is None:\n    raise ValueError('provider_uri is required — set it to a data path such as ~/.qlib/qlib_data/cn_data')","typeGuard":"def is_valid_provider_uri(u) -> bool:\n    return u is not None","tryCatchPattern":null,"preventionTips":["Never pass provider_uri=cfg.get('provider_uri') without a default.","Fail fast in your own bootstrap code when required config keys are absent."],"tags":["qlib","config","provider-uri","validation"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}