{"record":{"id":"ea242295f33c4190","repo":"gastownhall/beads","slug":"cannot-access-file-w","errorCode":null,"errorMessage":"cannot access file: %w","messagePattern":"cannot access file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/markdown.go","lineNumber":125,"sourceCode":"func validateMarkdownPath(path string) (string, error) {\n\t// Clean the path\n\tcleanPath := filepath.Clean(path)\n\n\t// Prevent directory traversal\n\tif strings.Contains(cleanPath, \"..\") {\n\t\treturn \"\", fmt.Errorf(\"invalid file path: directory traversal not allowed\")\n\t}\n\n\t// Ensure it's a markdown file\n\text := strings.ToLower(filepath.Ext(cleanPath))\n\tif ext != \".md\" && ext != \".markdown\" {\n\t\treturn \"\", fmt.Errorf(\"invalid file type: only .md and .markdown files are supported\")\n\t}\n\n\t// Check file exists and is not a directory\n\tinfo, err := os.Stat(cleanPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"cannot access file: %w\", err)\n\t}\n\tif info.IsDir() {\n\t\treturn \"\", fmt.Errorf(\"path is a directory, not a file\")\n\t}\n\n\treturn cleanPath, nil\n}\n\n// parseMarkdownFile parses a markdown file and extracts issue templates.\n// Expected format:\n//\n//\t## Issue Title\n//\tDescription text...\n//\n//\t### Priority\n//\t2\n//\n//\t### Type","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/markdown.go#L107-L143","documentation":"After extension checks, validateMarkdownPath calls os.Stat on the cleaned path; any stat failure (most commonly the file not existing, but also permission errors on parent directories) is wrapped as \"cannot access file: <os error>\". This is a pre-flight existence check before opening the file.","triggerScenarios":"parseMarkdownFile is called with a well-formed .md path that does not exist, sits in a directory the process cannot traverse, or has a symlink loop / too-long path causing os.Stat to error.","commonSituations":"Typo in filename; running from the wrong working directory; relative path resolved against an unexpected cwd in scripts; deleted temp files; permission-restricted directories.","solutions":["Verify the exact path exists: `ls -l <path>` (watch the working directory for relative paths)","Fix typos or use an absolute path","Check directory permissions (`chmod`/`chown`) so the bd process can traverse the path","If the file was generated by a prior step, confirm that step succeeded before importing"],"exampleFix":"// before\nparseMarkdownFile(\"isues.md\")\n// after\nparseMarkdownFile(\"./issues.md\")   // correct spelling, verified with ls","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(path); err != nil {\n\treturn fmt.Errorf(\"file missing or inaccessible: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify paths with ls/test -f before import","Use absolute paths to avoid cwd surprises","Ensure bd's user has traverse permissions on all path components"],"tags":["file-not-found","filesystem","io"],"backgroundTag":"file-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}