{"record":{"id":"9f68d0c6e1b64748","repo":"gastownhall/beads","slug":"line-d-dep-requires-a-subcommand-add-remove","errorCode":null,"errorMessage":"line %d: 'dep' requires a subcommand (add|remove)","messagePattern":"line (.+?): 'dep' requires a subcommand \\(add\\|remove\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/batch.go","lineNumber":276,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"line %d: %w\", lineNo, err)\n\t\t}\n\t\tif len(tokens) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\top := batchOp{line: lineNo, raw: trimmed}\n\t\tswitch tokens[0] {\n\t\tcase \"close\":\n\t\t\top.cmd = \"close\"\n\t\t\top.args = tokens[1:]\n\t\tcase \"update\":\n\t\t\top.cmd = \"update\"\n\t\t\top.args = tokens[1:]\n\t\tcase \"create\":\n\t\t\top.cmd = \"create\"\n\t\t\top.args = tokens[1:]\n\t\tcase \"dep\":\n\t\t\tif len(tokens) < 2 {\n\t\t\t\treturn nil, fmt.Errorf(\"line %d: 'dep' requires a subcommand (add|remove)\", lineNo)\n\t\t\t}\n\t\t\tswitch tokens[1] {\n\t\t\tcase \"add\":\n\t\t\t\top.cmd = \"dep.add\"\n\t\t\tcase \"remove\", \"rm\":\n\t\t\t\top.cmd = \"dep.remove\"\n\t\t\tdefault:\n\t\t\t\treturn nil, fmt.Errorf(\"line %d: unknown dep subcommand %q (want add|remove)\", lineNo, tokens[1])\n\t\t\t}\n\t\t\top.args = tokens[2:]\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"line %d: unsupported batch command %q (supported: close, update, create, dep add, dep remove)\", lineNo, tokens[0])\n\t\t}\n\t\tops = append(ops, op)\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/batch.go#L258-L294","documentation":"The `dep` batch command is a two-level command requiring a subcommand (`add` or `remove`). If a line starts with `dep` but has no second token, `parseBatchScript` rejects the whole script with this message before any writes occur.","triggerScenarios":"A batch script line reading just `dep` (e.g. `dep` alone, or `dep` at end of a truncated line) passed to `bd batch`.","commonSituations":"Truncated lines in generated scripts; users assuming `dep` alone lists dependencies (it does not in batch mode); copy-paste dropping the `add bd-1 bd-2` tail.","solutions":["Add the subcommand: use `dep add <child> <parent>` or `dep remove <child> <parent>` on that line.","If you intended to inspect dependencies, use `bd dep <id>` outside batch mode instead.","Validate with `bd batch --dry-run` before executing."],"exampleFix":"// before (batch file)\ndep bd-1 bd-2\n// after\ndep add bd-1 bd-2","handlingStrategy":"validation","validationCode":"# Ensure every 'dep' line has a valid subcommand before running:\nawk '$1==\"dep\" && !(($2==\"add\")||($2==\"remove\")||($2==\"rm\")) { print \"bad dep line \" NR \": \" $0 }' batch.txt","typeGuard":null,"tryCatchPattern":"if err := runBdBatch(file); err != nil {\n    if strings.Contains(err.Error(), \"'dep' requires a subcommand\") {\n        return fmt.Errorf(\"script rejected, no writes made: %w\", err)\n    }\n    return err\n}","preventionTips":["Use the full form `dep add <child> <parent>` / `dep remove <child> <parent>` in scripts.","Run dependency queries with `bd dep <id>` outside batch mode.","Lint batch files with `bd batch --dry-run` in CI before applying."],"tags":["cli","batch","parsing","dependencies"],"backgroundTag":"batch-script-parse-error","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}