{"record":{"id":"6f5289d596465422","repo":"666ghj/MiroFish","slug":"label-exceeded-the-size-limit","errorCode":null,"errorMessage":"{label} exceeded the size limit","messagePattern":"(.+?) exceeded the size limit","errorType":"exception","errorClass":"StarHistoryError","httpStatus":null,"severity":"error","filePath":"scripts/star_history.py","lineNumber":506,"sourceCode":"            raise StarHistoryError(\"output file cannot be a symbolic link\")\n    try:\n        resolved_parent = target.parent.resolve(strict=False)\n        resolved_parent.relative_to(root)\n    except (OSError, ValueError) as exc:\n        raise StarHistoryError(\"output path escaped the workspace\") from exc\n    return resolved_parent / target.name\n\n\ndef _read_limited(path: Path, limit: int, label: str) -> bytes:\n    try:\n        with path.open(\"rb\") as handle:\n            payload = handle.read(limit + 1)\n    except FileNotFoundError as exc:\n        raise StarHistoryError(f\"{label} is missing\") from exc\n    except OSError as exc:\n        raise StarHistoryError(f\"could not read {label}\") from exc\n    if len(payload) > limit:\n        raise StarHistoryError(f\"{label} exceeded the size limit\")\n    return payload\n\n\ndef load_star_count_file(path: Path) -> int:\n    \"\"\"Read a tiny, symlink-safe decimal count produced by the fetch-only step.\"\"\"\n\n    flags = os.O_RDONLY\n    if hasattr(os, \"O_NOFOLLOW\"):\n        flags |= os.O_NOFOLLOW\n    try:\n        descriptor = os.open(path, flags)\n    except OSError as exc:\n        raise StarHistoryError(\"Star count file is missing or unsafe\") from exc\n    try:\n        metadata = os.fstat(descriptor)\n        if not stat.S_ISREG(metadata.st_mode):\n            raise StarHistoryError(\"Star count file is not a regular file\")\n        payload = os.read(descriptor, MAX_COUNT_FILE_BYTES + 1)","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/scripts/star_history.py#L488-L524","documentation":"_read_limited reads limit+1 bytes up front; if the payload exceeds the cap (MAX_STATE_BYTES = 5,000,000 for history state), it raises '{label} exceeded the size limit'. This bounds memory use and rejects absurd state files before JSON parsing.","triggerScenarios":"history.json grows past 5 MB — many daily reconstruction points and snapshots accumulated over years, or the file was corrupted/appended with junk. Reading limit+1 bytes guarantees detection even when the file is exactly one byte over.","commonSituations":"Long-lived repositories with tens of thousands of stargazers and years of snapshots, accidentally committing a concatenated/merged state file, or hand-edits that duplicated content.","solutions":["Check the size: stat -c %s .github/star-history/history.json","If legitimate growth, the data must be trimmed per the tool's model (regenerate state via backfill, or prune per the project's state format) — do not blindly raise MAX_STATE_BYTES unless you own the script","Diff against git history to detect accidental duplication/appending","Regenerate the state from the fetch/backfill step"],"exampleFix":"# inspect what inflated the file\npython -c \"import json;d=json.load(open('.github/star-history/history.json'));print(len(d['snapshots']),len(d['reconstruction']['points']))\"","handlingStrategy":"validation","validationCode":"MAX = 5_000_000\nsize = (ws / '.github/star-history/history.json').stat().st_size\nif size > MAX: raise RuntimeError(f'state is {size} bytes (cap {MAX})')","typeGuard":null,"tryCatchPattern":"except StarHistoryError as e:\n    if str(e) == \"history state exceeded the size limit':\n        audit_and_regenerate(ws)  # detect duplication vs real growth\n    raise","preventionTips":["Monitor state file size across releases","Never append/concatenate into history.json","Regenerate state rather than hand-merging","Commit after each tool write so git bisect can find inflation"],"tags":["state","size-limit","corruption"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}