{"record":{"id":"e585d9a150c0eac0","repo":"gastownhall/beads","slug":"read-dependency-file-w","errorCode":null,"errorMessage":"read dependency file: %w","messagePattern":"read dependency file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/dep.go","lineNumber":674,"sourceCode":"\t\tdt := canonicalDependencyType(types.DependencyType(depType))\n\t\ttypeErr := validateDependencyType(dt)\n\t\tif typeErr != nil {\n\t\t\terrs = append(errs, fmt.Sprintf(\"line %d: %v\", lineNo, typeErr))\n\t\t}\n\t\tif from == \"\" || to == \"\" || typeErr != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tedges = append(edges, bulkDepEdge{\n\t\t\tLine:        lineNo,\n\t\t\tIssueID:     from,\n\t\t\tDependsOnID: to,\n\t\t\tType:        dt,\n\t\t\tDefaulted:   defaulted,\n\t\t})\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"read dependency file: %w\", err)\n\t}\n\tif len(errs) > 0 {\n\t\treturn nil, bulkDepValidationError(errs)\n\t}\n\treturn edges, nil\n}\n\nfunc validateBulkDepEdges(ctx context.Context, edges []bulkDepEdge) ([]bulkDepEdge, error) {\n\tresolved := make([]bulkDepEdge, 0, len(edges))\n\tvar errs []string\n\n\tfor _, edge := range edges {\n\t\tcurrent := edge\n\t\t// Write-intent: addBulkDependencies writes through current.Store (the\n\t\t// source issue's store), so a routed source must open writable (#4141);\n\t\t// the depends-on target below stays read-only (bd-6dnrw.32, GH#3231).\n\t\tfromID, fromStore, fromCleanup, err := resolveIDForMutation(ctx, store, edge.IssueID)\n\t\tif err != nil {","sourceCodeStart":656,"sourceCodeEnd":692,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/dep.go#L656-L692","documentation":"Wraps bufio.Scanner errors encountered while streaming the bulk dependency file in readBulkDepEdges. os.Open succeeded but a read failed mid-scan (I/O error, device disconnected, binary garbage causing scanner issues on huge lines). Thrown after the parse loop finishes if scanner.Err() is non-nil.","triggerScenarios":"Calling `bd dep add -f <file>` where the underlying file descriptor fails during scanning: hardware/disk I/O error, file truncated or removed mid-read (e.g. reading from /proc-like or FIFO), or lines exceeding bufio.Scanner's 64KB default token limit.","commonSituations":"A very long dependency line in the file exceeding the 64KB bufio.Scanner buffer; networked filesystem dropout; file replaced while a long-running bulk add is in progress.","solutions":["Check for unusually long lines in the file (awk 'length($0)>65536' deps.txt) and split them; the default scanner limit is 64KB per line.","Re-run the command — transient I/O errors (NFS, removable media) often clear on retry.","Verify the file is plain text, not binary or compressed (file deps.txt).","If lines are legitimately huge, pre-split the file into smaller chunk files and run one bulk add per chunk."],"exampleFix":"// before (one enormous line, >64KB, fails with 'bufio.Scanner: token too long')\nbd dep add bd-1 --file huge-deps.txt\n\n// after: split into chunks under the scanner limit\nsplit -l 1000 huge-deps.txt chunk-\nfor c in chunk-*; do bd dep add bd-1 --file \"$c\"; done","handlingStrategy":"retry","validationCode":"// ensure no line exceeds bufio.Scanner's 64KB default limit\nawk 'length($0) > 65536 { print \"line \" NR \" too long (\" length($0) \" chars)\"; bad=1 } END { exit bad }' \"$DEPS_FILE\"","typeGuard":null,"tryCatchPattern":"for attempt in 1 2 3; do\n  bd dep add bd-1 --file deps.txt && break\n  sleep $((attempt * 2))\ndone","preventionTips":["Keep dependency-file lines short; split bulk lists into chunks.","Do not modify or replace the file while a bulk add is running.","Avoid reading dependency files from flaky network mounts; copy locally first."],"tags":["file-io","scanner","dependencies"],"backgroundTag":"file-read-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}