{"record":{"id":"d0a9d271fbbe6b2a","repo":"666ghj/MiroFish","slug":"label-is-missing","errorCode":null,"errorMessage":"{label} is missing","messagePattern":"(.+?) is missing","errorType":"exception","errorClass":"StarHistoryError","httpStatus":null,"severity":"error","filePath":"scripts/star_history.py","lineNumber":502,"sourceCode":"            current = current / part\n            if current.is_symlink():\n                raise StarHistoryError(\"output directory cannot be a symbolic link\")\n        if target.is_symlink():\n            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:","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/scripts/star_history.py#L484-L520","documentation":"_read_limited wraps file reads; FileNotFoundError is mapped to '{label} is missing'. In practice label is 'history state' (from load_state reading .github/star-history/history.json), so the message reads 'history state is missing'. The tool treats a absent state file as an error rather than silently starting fresh.","triggerScenarios":"Calling load_state(workspace) on a workspace that has never run the backfill/render steps, after the state file was deleted or gitignored, or when the wrong workspace path was passed so the relative join misses the real file.","commonSituations":"First run on a fresh clone, CI pipelines that clean untracked files, accidentally passing repo parent instead of repo root, or moving the repo without .github.","solutions":["Run the fetch/backfill step first to generate .github/star-history/history.json before loading","Confirm the workspace argument points at the checkout containing .github","If the file was deleted, restore from git: git checkout -- .github/star-history/history.json","Check .gitignore is not excluding the state path in shared environments"],"exampleFix":"# before\nstate = load_state(workspace)\n# after\ngenerate_state(workspace, github, now=...)  # produces history.json first\nstate = load_state(workspace)","handlingStrategy":"validation","validationCode":"def state_exists(ws: Path) -> bool:\n    return (ws / Path('.github/star-history/history.json')).is_file()","typeGuard":"def ready_to_load(ws: Path) -> bool:\n    p = ws / Path('.github/star-history/history.json')\n    return p.exists() and not p.is_symlink()","tryCatchPattern":"try:\n    state = load_state(ws)\nexcept StarHistoryError as e:\n    if str(e) == \"history state is missing\":\n        state = generate_state(ws, github)  # first-run bootstrap\n    else: raise","preventionTips":["Run fetch/backfill before load in pipelines","Commit the state file to git","Assert the workspace arg is the repo root in wrappers","Restore via git checkout when deleted"],"tags":["state","file-not-found","workflow"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}