anthropics/financial-services · error · FileNotFoundError

File not found: {excel_path}

Error message

File not found: {excel_path}

What it means

Raised in DCFModelValidator.__init__ when Path(excel_path).exists() is False, i.e. the Excel file the validator was asked to inspect does not exist on disk. It fires before any workbook loading (openpyxl.load_workbook is only called after this check) so no partial state is created. The path in the message is echoed verbatim from the constructor argument.

Source

Thrown at plugins/agent-plugins/model-builder/skills/dcf-model/scripts/validate_dcf.py:26

import json
from pathlib import Path
from typing import Optional


class DCFModelValidator:
    """Validates DCF models for errors and quality issues"""

    def __init__(self, excel_path: str):
        try:
            import openpyxl
        except ImportError:
            raise ImportError("openpyxl not installed. Run: pip install openpyxl")

        self.excel_path = excel_path
        self.openpyxl = openpyxl

        if not Path(excel_path).exists():
            raise FileNotFoundError(f"File not found: {excel_path}")

        self.workbook_formulas = openpyxl.load_workbook(excel_path, data_only=False)
        self.workbook_values = openpyxl.load_workbook(excel_path, data_only=True)
        self.errors = []
        self.warnings = []
        self.info = []
        
    def validate_all(self) -> dict:
        """
        Run all validation checks

        Returns:
            Dict with validation results
        """
        from datetime import datetime

        self.check_sheet_structure()
        self.check_formula_errors()

View on GitHub (pinned to 69cbc81467)

Solutions

  1. Check the file exists from the same CWD the script runs in: ls -l '<path>' or Path(path).resolve() and print it before constructing the validator
  2. Use an absolute path: DCFModelValidator(str(Path('model.xlsx').resolve()))
  3. If the path comes from CLI/LLM output, strip whitespace and quotes before passing it
  4. If an upstream step was supposed to create the file, verify that step succeeded and where it wrote output (check its logs/temp dir)

Example fix

# before
validator = DCFModelValidator('models/dcf.xlsx')  # FileNotFoundError

# after
from pathlib import Path
p = Path('models/dcf.xlsx').resolve()
if not p.is_file():
    raise SystemExit(f'Missing model file: {p}')
validator = DCFModelValidator(str(p))
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
p = Path(excel_path).expanduser().resolve()
if not p.is_file():
    raise SystemExit(f'Model file not found: {p}')
validator = DCFModelValidator(str(p))

Type guard

def is_valid_model_path(raw: str) -> bool:
    p = Path(raw).expanduser()
    return p.is_file() and p.suffix.lower() in {'.xlsx', '.xlsm'}

Try / catch

try:
    validator = DCFModelValidator(path)
except FileNotFoundError as e:
    raise SystemExit(f'Could not open model: {e}. Check the path and that the export step produced the file.')

Prevention

When it happens

Trigger: Calling DCFModelValidator(excel_path) with a wrong relative path (relative to the process CWD, not the script), a filename typo, a path to a file on another machine/share, or a file that an upstream step (e.g. an export or generation step) failed to produce. Only the message template is shown here; the actual error interpolates the given path.

Common situations: Agent/skill workflows where the model file is generated in a temp dir but validated from a different CWD; case-sensitive filesystems (Model.XLSX vs model.xlsx); Windows path separators passed on POSIX or vice versa; trailing quotes/whitespace in paths parsed from CLI args or LLM output; files cleaned up by a temp-dir cleanup race.

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


AI-assisted analysis of anthropics/financial-services@69cbc81467 (2026-08-27). Data as JSON: /api/errors/5ad100c405f3565f. Report an issue: GitHub.