{"record":{"id":"cf14b45a790387d3","repo":"rohitg00/ai-engineering-from-scratch","slug":"at-least-one-shard-entry-is-required","errorCode":null,"errorMessage":"at least one shard entry is required","messagePattern":"at least one shard entry is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phases/19-capstone-projects/43-hdf5-tokenized-corpus/code/main.py","lineNumber":265,"sourceCode":"            \"total_tokens\": running_offset,\n            \"shards\": [entry.to_dict() for entry in entries],\n        }\n        index_path.write_text(json.dumps(body, sort_keys=True, indent=2), encoding=\"utf-8\")\n        return entries\n\n\nclass MmapTokenStore:\n    \"\"\"Memory-mapped read access to a sharded HDF5 token corpus.\n\n    The store opens each shard file once in SWMR mode. A request for\n    `get_slice(start, stop)` is routed across shards and the result is returned\n    as a flat NumPy uint16 array. Reads land in the page cache; the dataloader\n    pays one copy when it crosses into a training tensor.\n    \"\"\"\n\n    def __init__(self, shard_entries: list[ShardIndexEntry]) -> None:\n        if not shard_entries:\n            raise ValueError(\"at least one shard entry is required\")\n        self._entries = shard_entries\n        self._files: list[h5py.File] = []\n        self._datasets: list[h5py.Dataset] = []\n        try:\n            for entry in shard_entries:\n                self._files.append(h5py.File(entry.path, \"r\", swmr=True))\n            self._datasets = [f[\"tokens\"] for f in self._files]\n        except Exception:\n            for opened in self._files:\n                try:\n                    opened.close()\n                except Exception:\n                    pass\n            self._files = []\n            self._datasets = []\n            raise\n        self._total_tokens = sum(entry.token_count for entry in shard_entries)\n","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/19-capstone-projects/43-hdf5-tokenized-corpus/code/main.py#L247-L283","documentation":"Error \"at least one shard entry is required\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/19-capstone-projects/43-hdf5-tokenized-corpus/code/main.py:265 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}