{"record":{"id":"098fcdf321eefa0a","repo":"666ghj/MiroFish","slug":"could-not-read-label","errorCode":null,"errorMessage":"could not read {label}","messagePattern":"could not read (.+?)","errorType":"exception","errorClass":"StarHistoryError","httpStatus":null,"severity":"error","filePath":"scripts/star_history.py","lineNumber":504,"sourceCode":"                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:\n        metadata = os.fstat(descriptor)\n        if not stat.S_ISREG(metadata.st_mode):","sourceCodeStart":486,"sourceCodeEnd":522,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/scripts/star_history.py#L486-L522","documentation":"_read_limited maps any non-ENOENT OSError while opening/reading the file to 'could not read {label}' ('could not read history state'). __cause__ preserves the original errno for diagnosis.","triggerScenarios":"Opening .github/star-history/history.json fails with EACCES (no read permission), EISDIR, EMFILE (fd exhaustion), or a read() interrupted by an I/O error (bad disk, NFS stale handle). Distinct from 166 because the file exists but is unreadable.","commonSituations":"Files owned by root from a previous container run, restrictive umasks in CI, state written by a different user, or flaky network filesystems holding the checkout.","solutions":["Inspect exc.__cause__ (errno) from the caught StarHistoryError","chmod/chown the state file so the invoking user can read it","If on NFS/network storage, retry or move the workspace local","Check fd limits (ulimit -n) if EMFILE"],"exampleFix":"# before: written by root in a container step\nsudo python scripts/star_history.py ...\n# after\npython scripts/star_history.py ...  # same user reads and writes","handlingStrategy":"try-catch","validationCode":"import os\np = ws / '.github/star-history/history.json'\nif p.exists() and not os.access(p, os.R_OK):\n    raise PermissionError(f'no read access: {p}')","typeGuard":null,"tryCatchPattern":"except StarHistoryError as e:\n    if str(e) == \"could not read history state\" and e.__cause__:\n        handle_errno(e.__cause__.errno)  # EACCES -> chmod, EIO -> retry\n    raise","preventionTips":["Read and write state as the same OS user","Avoid root-written artifacts in containers","Check ulimit -n when running many parallel jobs","Prefer local disk over NFS for state"],"tags":["filesystem","permissions","io-error","state"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}