{"record":{"id":"c2dd49827db6a339","repo":"666ghj/MiroFish","slug":"could-not-create-output-directory","errorCode":null,"errorMessage":"could not create output directory","messagePattern":"could not create output directory","errorType":"exception","errorClass":"StarHistoryError","httpStatus":null,"severity":"error","filePath":"scripts/star_history.py","lineNumber":481,"sourceCode":"\ndef _safe_target(workspace: Path, relative: Path, create_parent: bool) -> Path:\n    root = _safe_workspace(workspace)\n    if relative.is_absolute() or \"..\" in relative.parts:\n        raise StarHistoryError(\"output path escaped the workspace\")\n\n    current = root\n    for part in relative.parts[:-1]:\n        current = current / part\n        if current.is_symlink():\n            raise StarHistoryError(\"output directory cannot be a symbolic link\")\n    target = root / relative\n    if target.is_symlink():\n        raise StarHistoryError(\"output file cannot be a symbolic link\")\n    if create_parent:\n        try:\n            target.parent.mkdir(parents=True, exist_ok=True)\n        except OSError as exc:\n            raise StarHistoryError(\"could not create output directory\") from exc\n        current = root\n        for part in relative.parts[:-1]:\n            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:","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/scripts/star_history.py#L463-L499","documentation":"Raised by _safe_target when Path.mkdir(parents=True, exist_ok=True) on the output's parent directory raises OSError. The raw OS error is chained (__cause__) so the underlying errno is preserved in the traceback.","triggerScenarios":"Calling _safe_target(workspace, relative, create_parent=True) (i.e. save paths) when the parent chain cannot be created: EACCES/EPERM on the workspace dir, ENOSPC (disk full), EEXIST because a path component already exists as a regular file (e.g. a file literally named '.github/star-history'), EROFS on a read-only filesystem, or EDQUOT quota exceeded.","commonSituations":"Running the tool in CI as a non-owner user against a checked-out repo, disk-full build agents, a stray file named like the state directory, or containers with a read-only layer at that path.","solutions":["Inspect exc.__cause__ from the StarHistoryError to get the errno","Ensure the invoking user has write permission on the workspace (or run with appropriate ownership)","Remove any regular file occupying the directory path: find . -name 'star-history' -type f","Free disk space / raise quota, or point the workspace at a writable location"],"exampleFix":"# before: a file blocks the directory path\n.github/star-history  (regular file)\n# after\nrm .github/star-history && mkdir -p .github/star-history","handlingStrategy":"try-catch","validationCode":"parent = (ws / rel).parent\nif parent.exists() and not parent.is_dir():\n    raise RuntimeError(f\"{parent} exists but is not a directory\")\nimport os\nif not os.access(ws, os.W_OK):\n    raise RuntimeError(\"workspace not writable\")","typeGuard":null,"tryCatchPattern":"try:\n    _safe_target(ws, rel, create_parent=True)\nexcept StarHistoryError as e:\n    if str(e) == \"could not create output directory\" and e.__cause__:\n        errno = e.__cause__.errno  # EACCES/ENOSPC/EEXIST/EROFS -> targeted fix\n    raise","preventionTips":["Check writable workspace and free disk before runs","Never create files named like the state directory","Run read/write steps as the same user","df -h before large pipeline stages"],"tags":["filesystem","permissions","disk-full","state"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}