JuliusBrussee/caveman · error · FileNotFoundError
File not found: {filepath}
Error message
File not found: {filepath} What it means
Raised by compress_file() after resolving the argument with Path.resolve(): the target file does not exist on disk. The check runs before size/sensitivity checks, so a nonexistent path always fails here first, with the resolved absolute path in the message.
Source
Thrown at skills/caveman-compress/scripts/compress.py:282
ORIGINAL (reference only):
{original}
COMPRESSED (fix this):
{compressed}
Return ONLY the fixed compressed file. No explanation.
"""
# ---------- Core Logic ----------
def compress_file(filepath: Path) -> bool:
# Resolve and validate path
filepath = filepath.resolve()
MAX_FILE_SIZE = 500_000 # 500KB
if not filepath.exists():
raise FileNotFoundError(f"File not found: {filepath}")
if filepath.stat().st_size > MAX_FILE_SIZE:
raise ValueError(f"File too large to compress safely (max 500KB): {filepath}")
# Refuse files that look like they contain secrets or PII. Compressing ships
# the raw bytes to the Anthropic API — a third-party boundary — so we fail
# loudly rather than silently exfiltrate credentials or keys. Override is
# intentional: the user must rename the file if the heuristic is wrong.
if is_sensitive_path(filepath):
raise ValueError(
f"Refusing to compress {filepath}: filename looks sensitive "
"(credentials, keys, secrets, or known private paths). "
"Compression sends file contents to the Anthropic API. "
"Rename the file if this is a false positive."
)
print(f"Processing: {filepath}")
if not should_compress(filepath):View on GitHub (pinned to 27d5a3981a)
Solutions
- Check the resolved path printed in the error with ls — it is absolute, so cwd confusion is ruled out.
- Fix the typo or pass the correct current location of the file.
- If the file was expected to exist, find where it moved (git status / glob for the filename) and re-run with the new path.
Example fix
# before
compress_file(Path('docs/README-caveman.md')) # FileNotFoundError: .../docs/README-caveman.md
# after
compress_file(Path('docs/README.md')) Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
def compressible_path(raw: str) -> bool:
p = Path(raw).resolve()
return p.is_file() and not p.is_symlink() or p.exists() Try / catch
try:
compress_file(path)
except FileNotFoundError as e:
# resolved absolute path is in the message; locate the moved file and re-run
path = relocate(path)
raise Prevention
- Pass absolute paths to compress_file — resolve() makes the error message unambiguous.
- Verify existence (Path(p).is_file()) in the calling agent before invoking the skill.
- Re-glob for the filename if it was renamed instead of guessing paths.
When it happens
Trigger: Invoking the compress skill or compress.py with a path that is misspelled, relative to a different cwd, already deleted/moved, or a symlink whose target is gone (resolve() surfaces the dead target).
Common situations: Agent passes a path quoted from an old conversation after the file was renamed; relative paths evaluated from a different working directory; case-sensitivity mismatches on Linux; a temp file cleaned up mid-session.
Related errors
- repository intelligence: cwd is not a directory
- File too large to compress safely (max 500KB): {filepath}
- resolve fixture directory: %w
- invalid fixture path %q
- native session key length = %d, want %d
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/6223e63f0c7c6d1f.
Report an issue: GitHub.