{"record":{"id":"f6c625e6072ba406","repo":"anthropics/financial-services","slug":"file-not-found-excel-path-f6c625","errorCode":null,"errorMessage":"File not found: {excel_path}","messagePattern":"File not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"plugins/agent-plugins/pitch-agent/skills/dcf-model/scripts/validate_dcf.py","lineNumber":26,"sourceCode":"import json\nfrom pathlib import Path\nfrom typing import Optional\n\n\nclass DCFModelValidator:\n    \"\"\"Validates DCF models for errors and quality issues\"\"\"\n\n    def __init__(self, excel_path: str):\n        try:\n            import openpyxl\n        except ImportError:\n            raise ImportError(\"openpyxl not installed. Run: pip install openpyxl\")\n\n        self.excel_path = excel_path\n        self.openpyxl = openpyxl\n\n        if not Path(excel_path).exists():\n            raise FileNotFoundError(f\"File not found: {excel_path}\")\n\n        self.workbook_formulas = openpyxl.load_workbook(excel_path, data_only=False)\n        self.workbook_values = openpyxl.load_workbook(excel_path, data_only=True)\n        self.errors = []\n        self.warnings = []\n        self.info = []\n        \n    def validate_all(self) -> dict:\n        \"\"\"\n        Run all validation checks\n\n        Returns:\n            Dict with validation results\n        \"\"\"\n        from datetime import datetime\n\n        self.check_sheet_structure()\n        self.check_formula_errors()","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/anthropics/financial-services/blob/69cbc81467a5dced793eee03dec4658aa24ef856/plugins/agent-plugins/pitch-agent/skills/dcf-model/scripts/validate_dcf.py#L8-L44","documentation":"Raised in DCFModelValidator.__init__ of the pitch-agent copy of validate_dcf.py when Path(excel_path).exists() is False, i.e. the Excel workbook to validate does not exist on disk. It fires before openpyxl.load_workbook is called, so no workbook state is created. The actual message interpolates the exact path passed to the constructor.","triggerScenarios":"Calling DCFModelValidator(excel_path) with a path relative to the wrong CWD, a typo, or a model file that the pitch-generation step never produced. Only the message template appears here; at runtime it contains the concrete path.","commonSituations":"Agent pipelines that generate the deck/model in a temp directory then validate from a different working directory; case mismatches on case-sensitive filesystems; paths copy-pasted from Windows (backslashes) on POSIX; paths extracted from LLM/CLI output containing quotes or stray whitespace.","solutions":["Confirm the file from the script's CWD: ls -l '<path>'; if missing, locate the real output location","Pass an absolute resolved path: DCFModelValidator(str(Path(x).resolve()))","Sanitize externally sourced paths: p = raw.strip().strip('\"\\'')","If an upstream generation step should have written the file, check its logs/temp dir for where (or whether) it wrote output"],"exampleFix":"# before\nvalidator = DCFModelValidator('output/pitch_dcf.xlsx')  # FileNotFoundError\n\n# after\nfrom pathlib import Path\np = Path('output/pitch_dcf.xlsx').resolve()\nif not p.is_file():\n    raise SystemExit(f'Missing model file: {p}')\nvalidator = DCFModelValidator(str(p))","handlingStrategy":"validation","validationCode":"from pathlib import Path\np = Path(excel_path).expanduser().resolve()\nif not p.is_file():\n    raise SystemExit(f'Model file not found: {p}')\nvalidator = DCFModelValidator(str(p))","typeGuard":"def is_valid_model_path(raw: str) -> bool:\n    p = Path(raw).expanduser()\n    return p.is_file() and p.suffix.lower() in {'.xlsx', '.xlsm'}","tryCatchPattern":"try:\n    validator = DCFModelValidator(path)\nexcept FileNotFoundError as e:\n    raise SystemExit(f'Could not open model: {e}. Check the path and where the generation step wrote its output.')","preventionTips":["Resolve to absolute paths before constructing the validator","Normalize paths coming from agent output or CLI args (strip quotes/whitespace)","Pin the working directory (os.chdir or absolute paths) in generate-then-validate pipelines"],"tags":["python","file-not-found","path","filesystem","excel"],"backgroundTag":"file-not-found","analyzedSha":"69cbc81467a5dced793eee03dec4658aa24ef856","analyzedAt":"2026-08-27T12:38:04.061Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}