microsoft/qlib · error · ValueError

storage.start_index or storage.end_index is None, storage ma

Error message

storage.start_index or storage.end_index is None, storage may not exist

What it means

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.

Source

Thrown at qlib/data/storage/storage.py:414

                >>> self.write([6, 7, 8], index=4)

                    feature:
                        3   3
                        4   6
                        5   7
                        6   8

                >>> self.rebase(start_index=4, end_index=5)

                    feature:
                        4   6
                        5   7

        """
        storage_si = self.start_index
        storage_ei = self.end_index
        if storage_si is None or storage_ei is None:
            raise ValueError("storage.start_index or storage.end_index is None, storage may not exist")

        start_index = storage_si if start_index is None else start_index
        end_index = storage_ei if end_index is None else end_index

        if start_index is None or end_index is None:
            logger.warning("both start_index and end_index are None, or storage does not exist; rebase is ignored")
            return

        if start_index < 0 or end_index < 0:
            logger.warning("start_index or end_index cannot be less than 0")
            return
        if start_index > end_index:
            logger.warning(
                f"start_index({start_index}) > end_index({end_index}), rebase is ignored; "
                f"if you need to clear the FeatureStorage, please execute: FeatureStorage.clear"
            )
            return

View on GitHub (pinned to 79633dd950)

Solutions

  1. Verify data exists before rebasing: check storage.start_index is not None and storage.end_index is not None
  2. Write/dump the feature data first (e.g. via dump_bin) so the storage exists, then call rebase
  3. Check the backing file path of the storage actually exists on disk
  4. Skip rebase for empty storages in batch pipelines instead of crashing

Example fix

# before
storage.rebase(start_index=100, end_index=200)  # ValueError if empty

# after
if storage.start_index is not None and storage.end_index is not None:
    storage.rebase(start_index=100, end_index=200)
else:
    logger.warning('skip rebase: storage %s is empty', storage)
Defensive patterns

Strategy: validation

Validate before calling

if storage.start_index is None or storage.end_index is None:
    raise FileNotFoundError(f'storage for {storage} is empty; dump data before rebase')

Try / catch

try:
    storage.rebase(si, ei)
except ValueError as e:
    if 'may not exist' in str(e):
        logger.warning('skip rebase for empty storage %s', storage)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15). Data as JSON: /api/errors/1adffc9149ee7d60. Report an issue: GitHub.