{"record":{"id":"8cb23957d959cc15","repo":"gastownhall/beads","slug":"open-dependency-file-w","errorCode":null,"errorMessage":"open dependency file: %w","messagePattern":"open dependency file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/dep.go","lineNumber":612,"sourceCode":"\t\t\t\"count\":        len(resolved),\n\t\t\t\"dependencies\": out,\n\t\t})\n\t}\n\n\tfmt.Printf(\"%s Added %d dependencies\\n\", ui.RenderPass(\"✓\"), len(resolved))\n\treturn nil\n}\n\nfunc readBulkDepEdges(file string, defaultType string) ([]bulkDepEdge, error) {\n\tvar r io.Reader\n\tvar f *os.File\n\tif file == \"-\" {\n\t\tr = os.Stdin\n\t} else {\n\t\tvar err error\n\t\tf, err = os.Open(file) // #nosec G304 -- user-supplied bulk dependency file\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"open dependency file: %w\", err)\n\t\t}\n\t\tdefer f.Close()\n\t\tr = f\n\t}\n\n\tscanner := bufio.NewScanner(r)\n\tscanner.Buffer(make([]byte, 0, 64*1024), 1024*1024)\n\n\tvar edges []bulkDepEdge\n\tvar errs []string\n\tlineNo := 0\n\tfor scanner.Scan() {\n\t\tlineNo++\n\t\tline := strings.TrimSpace(scanner.Text())\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tvar in bulkDepInput","sourceCodeStart":594,"sourceCodeEnd":630,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/dep.go#L594-L630","documentation":"Wraps the OS error returned by os.Open when readBulkDepEdges cannot open the user-supplied bulk dependency file (any file other than '-'). It lets `bd dep add -f <file>` fail with context about which step failed while preserving the underlying errno message. It is thrown in cmd/bd/dep.go when the file path is wrong, unreadable, or a directory.","triggerScenarios":"Running `bd dep add --file <path>` (via addBulkDependencies or runDepAddBulkProxied) where os.Open fails: nonexistent path, no read permission, path is a directory, or a stale symlink.","commonSituations":"Typo in the -f path; running from a different working directory than assumed; file deleted after shell globbing; permission-restricted mount or CI sandbox that blocks reading the dependency list.","solutions":["Verify the path exists and is readable: ls -l <file>, or cat <file> to confirm access.","If input should come from stdin, pass '-' as the file value (readBulkDepEdges maps '-' to os.Stdin).","Fix permissions (chmod/chown) or move the file into the directory where bd runs.","Check for a stale relative path and re-run with an absolute path."],"exampleFix":"// before\nbd dep add bd-1 --file ./deps.txt\n// error: open dependency file: no such file or directory\n\n// after\nbd dep add bd-1 --file \"$PWD/deps.txt\"  # or verify file exists first\n[ -r deps.txt ] && bd dep add bd-1 --file deps.txt","handlingStrategy":"validation","validationCode":"if [ ! -r \"$DEPS_FILE\" ] || [ -d \"$DEPS_FILE\" ]; then echo \"dependency file not readable: $DEPS_FILE\" >&2; exit 1; fi","typeGuard":null,"tryCatchPattern":"if err := addBulkDeps(file); err != nil {\n\tif errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission) {\n\t\tfmt.Fprintf(os.Stderr, \"cannot open %s: %v\\n\", file, err)\n\t\tos.Exit(1)\n\t}\n\treturn err\n}","preventionTips":["Always resolve the -f argument to an absolute path in scripts.","Use '-' with a heredoc/pipe when generating dependency lists dynamically.","Check file readability in CI before invoking bd dep add."],"tags":["file-io","cli","dependencies"],"backgroundTag":"file-open-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}