{"record":{"id":"089805eb38920233","repo":"nexu-io/open-design","slug":"last30days-cannot-read-synthesis-file-exc","errorCode":null,"errorMessage":"[last30days] Cannot read --synthesis-file: {exc}","messagePattern":"\\[last30days\\] Cannot read --synthesis-file: (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"design-templates/last30days/scripts/last30days.py","lineNumber":200,"sourceCode":"    slug = slugify(topic)\n    extension = \"json\" if emit == \"json\" else \"html\" if emit == \"html\" else \"md\"\n    raw_label = \"raw-html\" if emit == \"html\" else \"raw\"\n    suffix_part = f\"-{suffix}\" if suffix else \"\"\n    raw = path / f\"{slug}-{raw_label}{suffix_part}.{extension}\"\n    try:\n        home = _Path.home().resolve()\n        relative = raw.relative_to(home)\n        return f\"~/{relative}\"\n    except ValueError:\n        return str(raw)\n\n\ndef read_synthesis_file(path: str) -> str:\n    try:\n        return Path(path).expanduser().read_text(encoding=\"utf-8\")\n    except OSError as exc:\n        sys.stderr.write(f\"[last30days] Cannot read --synthesis-file: {exc}\\n\")\n        raise SystemExit(2)\n\n\ndef persist_report(report: schema.Report) -> dict[str, int]:\n    import store\n\n    store.init_db()\n    topic_row = store.add_topic(report.topic)\n    topic_id = topic_row[\"id\"]\n    source_mode = \",\".join(sorted(report.items_by_source)) or \"v3\"\n    run_id = store.record_run(topic_id, source_mode=source_mode, status=\"running\")\n    try:\n        findings = store.findings_from_report(report)\n        counts = store.store_findings(run_id, topic_id, findings)\n        store.update_run(\n            run_id,\n            status=\"completed\",\n            findings_new=counts[\"new\"],\n            findings_updated=counts[\"updated\"],","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/design-templates/last30days/scripts/last30days.py#L182-L218","documentation":"read_synthesis_file() expands the user path and calls Path.read_text(encoding='utf-8'). On any OSError (file missing, permission denied, ISDIR, broken symlink, decode-adjacent read failure) it writes a `[last30days] Cannot read --synthesis-file: <exc>` line to stderr and re-raises as SystemExit(2). The exception object is interpolated verbatim so the underlying errno/path is visible.","triggerScenarios":"`--synthesis-file ~/notes/synth.md` where the file does not exist, is a directory, has no read permission, or is on an unreadable mount.","commonSituations":"Typo in the path; ~ not expanded by the shell because the arg was quoted oddly (the code does call expanduser, so this is rare); permissions locked down; file on a disconnected network mount; pointing at a directory by mistake.","solutions":["Check the path exists and is a regular file: `test -f <path>`.","Check read permission: `ls -l <path>`; chmod if needed.","Use an absolute path to avoid ambiguity.","Ensure the file is UTF-8 decodable (the read uses encoding='utf-8')."],"exampleFix":"# before\npython3.12 last30days.py --topic x --synthesis-file ~/pres/synth.mdr\n# after (fix typo)\npython3.12 last30days.py --topic x --synthesis-file ~/pres/synth.md","handlingStrategy":"validation","validationCode":"from pathlib import Path\np = Path(path).expanduser()\nif not p.is_file():\n    raise FileNotFoundError(f'--synthesis-file not a readable file: {p}')\ntext = p.read_text(encoding='utf-8')","typeGuard":null,"tryCatchPattern":"from pathlib import Path\ntry:\n    synthesis = Path(path).expanduser().read_text(encoding='utf-8')\nexcept OSError as exc:\n    print(f'[last30days] Cannot read --synthesis-file: {exc}', file=sys.stderr)\n    sys.exit(2)","preventionTips":["Use absolute paths for file arguments.","Validate existence with os.path.isfile before calling the script."],"tags":["cli","filesystem","python","argument-validation"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}