{"record":{"id":"1adffc9149ee7d60","repo":"microsoft/qlib","slug":"storage-start-index-or-storage-end-index-is-none","errorCode":null,"errorMessage":"storage.start_index or storage.end_index is None, storage may not exist","messagePattern":"storage\\.start_index or storage\\.end_index is None, storage may not exist","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/data/storage/storage.py","lineNumber":414,"sourceCode":"                >>> self.write([6, 7, 8], index=4)\n\n                    feature:\n                        3   3\n                        4   6\n                        5   7\n                        6   8\n\n                >>> self.rebase(start_index=4, end_index=5)\n\n                    feature:\n                        4   6\n                        5   7\n\n        \"\"\"\n        storage_si = self.start_index\n        storage_ei = self.end_index\n        if storage_si is None or storage_ei is None:\n            raise ValueError(\"storage.start_index or storage.end_index is None, storage may not exist\")\n\n        start_index = storage_si if start_index is None else start_index\n        end_index = storage_ei if end_index is None else end_index\n\n        if start_index is None or end_index is None:\n            logger.warning(\"both start_index and end_index are None, or storage does not exist; rebase is ignored\")\n            return\n\n        if start_index < 0 or end_index < 0:\n            logger.warning(\"start_index or end_index cannot be less than 0\")\n            return\n        if start_index > end_index:\n            logger.warning(\n                f\"start_index({start_index}) > end_index({end_index}), rebase is ignored; \"\n                f\"if you need to clear the FeatureStorage, please execute: FeatureStorage.clear\"\n            )\n            return\n","sourceCodeStart":396,"sourceCodeEnd":432,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/storage/storage.py#L396-L432","documentation":"FeatureStorage.rebase (qlib/data/storage/storage.py:414) trims the stored data to the closed interval [start_index, end_index]. Before trimming it reads the storage's current range; if either storage_si or storage_ei is None (the documented signal that the storage/data does not exist), it raises ValueError('storage.start_index or storage.end_index is None, storage may not exist'). This is a fail-fast guard against rebasing empty storage.","triggerScenarios":"Calling storage.rebase(start_index, end_index) on a FeatureStorage whose start_index or end_index returns None — i.e. an empty or missing feature file; rebasing before any data has been written; a storage pointing at a deleted or never-dumped bin file.","commonSituations":"Running data-maintenance scripts that rebase ranges after deleting old data; calling rebase on an instrument/field combination that was never dumped; partially dumped datasets where some features are empty.","solutions":["Verify data exists before rebasing: check storage.start_index is not None and storage.end_index is not None","Write/dump the feature data first (e.g. via dump_bin) so the storage exists, then call rebase","Check the backing file path of the storage actually exists on disk","Skip rebase for empty storages in batch pipelines instead of crashing"],"exampleFix":"# before\nstorage.rebase(start_index=100, end_index=200)  # ValueError if empty\n\n# after\nif storage.start_index is not None and storage.end_index is not None:\n    storage.rebase(start_index=100, end_index=200)\nelse:\n    logger.warning('skip rebase: storage %s is empty', storage)","handlingStrategy":"validation","validationCode":"if storage.start_index is None or storage.end_index is None:\n    raise FileNotFoundError(f'storage for {storage} is empty; dump data before rebase')","typeGuard":null,"tryCatchPattern":"try:\n    storage.rebase(si, ei)\nexcept ValueError as e:\n    if 'may not exist' in str(e):\n        logger.warning('skip rebase for empty storage %s', storage)\n    else:\n        raise","preventionTips":["Always treat None start/end index as 'no data' and skip destructive range operations","In batch maintenance scripts, wrap rebase with an existence check per feature"],"tags":["qlib","storage","rebase","empty-storage","value-error"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}