deepset-ai/haystack · error · FileNotFoundError
File not found: {file_path}
Error message
File not found: {file_path} What it means
load_pipeline_snapshot() opens the given path to read a JSON snapshot and re-raises FileNotFoundError with the resolved path when the file does not exist. It exists so callers resuming from a saved breakpoint get a clear message naming the missing file.
Source
Thrown at haystack/core/pipeline/breakpoint.py:116
)
def load_pipeline_snapshot(file_path: str | Path) -> PipelineSnapshot:
"""
Load a saved pipeline snapshot.
:param file_path: Path to the pipeline_snapshot file.
:returns:
Dict containing the loaded pipeline_snapshot.
"""
file_path = Path(file_path)
try:
with open(file_path, encoding="utf-8") as f:
pipeline_snapshot_dict = json.load(f)
except FileNotFoundError as e:
raise FileNotFoundError(f"File not found: {file_path}") from e
except json.JSONDecodeError as e:
raise json.JSONDecodeError(f"Invalid JSON file {file_path}: {str(e)}", e.doc, e.pos) from e
except OSError as e:
raise OSError(f"Error reading {file_path}: {str(e)}") from e
try:
pipeline_snapshot = PipelineSnapshot.from_dict(pipeline_snapshot_dict)
except ValueError as e:
raise ValueError(f"Invalid pipeline snapshot from {file_path}: {str(e)}") from e
logger.info("Successfully loaded the pipeline snapshot from: {file_path}", file_path=file_path)
return pipeline_snapshot
def _save_pipeline_snapshot(
pipeline_snapshot: PipelineSnapshot,
raise_on_failure: bool = True,
snapshot_callback: SnapshotCallback | None = None,View on GitHub (pinned to e318778c9b)
Solutions
- Verify the file exists and fix the path: os.path.exists() / Path(file_path).resolve() before loading.
- Use absolute paths when saving and resuming snapshots to avoid cwd differences.
- Catch FileNotFoundError around load_pipeline_snapshot and prompt the user to re-save the snapshot.
Example fix
// before
snapshot = load_pipeline_snapshot("snapshot.json")
// after
from pathlib import Path
p = Path("snapshots").resolve() / "snapshot.json"
if not p.exists():
raise SystemExit(f"Snapshot missing: {p}")
snapshot = load_pipeline_snapshot(str(p)) Defensive patterns
Strategy: try-catch
Validate before calling
from pathlib import Path
p = Path(file_path)
if not p.is_file():
raise FileNotFoundError(f"Snapshot missing: {p.resolve()}") Type guard
def snapshot_file_exists(path) -> bool:
from pathlib import Path
return Path(path).is_file() Try / catch
try:
snapshot = load_pipeline_snapshot(file_path)
except FileNotFoundError as e:
logger.error("Snapshot file missing: %s", e) Prevention
- Check Path(file_path).is_file() before loading
- Use absolute paths when saving snapshots
- Avoid cleaning temp snapshot directories before resume completes
When it happens
Trigger: Calling load_pipeline_snapshot("path/to/snapshot.json") with a non-existent path; wrong working directory when a relative path is used; file deleted between save and resume.
Common situations: Typo in the snapshot file name; running the resume from a different cwd so a relative path no longer resolves; cleanup scripts removing tmp snapshot files before resume.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Error reading {file_path}: {str(e)}
- Invalid pipeline snapshot: components {invalid_ordered_compo
- Invalid pipeline snapshot: components {invalid_input_data} i
- Invalid pipeline snapshot: components {invalid_component_vis
- The following tool names are not valid: {invalid_tool_names}
AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30).
Data as JSON: /api/errors/c1f9b67d1909ec5d.
Report an issue: GitHub.