gastownhall/beads · error
line %d: unknown dep subcommand %q (want add|remove)
Error message
line %d: unknown dep subcommand %q (want add|remove)
What it means
In batch mode, `dep` only accepts `add`, `remove`, or `rm` as its subcommand. Any other second token (e.g. `dep list bd-1`) fails parsing of the entire script before any writes, with the offending subcommand quoted.
Source
Thrown at cmd/bd/batch.go:284
op.cmd = "close"
op.args = tokens[1:]
case "update":
op.cmd = "update"
op.args = tokens[1:]
case "create":
op.cmd = "create"
op.args = tokens[1:]
case "dep":
if len(tokens) < 2 {
return nil, fmt.Errorf("line %d: 'dep' requires a subcommand (add|remove)", lineNo)
}
switch tokens[1] {
case "add":
op.cmd = "dep.add"
case "remove", "rm":
op.cmd = "dep.remove"
default:
return nil, fmt.Errorf("line %d: unknown dep subcommand %q (want add|remove)", lineNo, tokens[1])
}
op.args = tokens[2:]
default:
return nil, fmt.Errorf("line %d: unsupported batch command %q (supported: close, update, create, dep add, dep remove)", lineNo, tokens[0])
}
ops = append(ops, op)
}
if err := scanner.Err(); err != nil {
return nil, err
}
return ops, nil
}
// tokenizeBatchLine splits a line into whitespace-separated tokens with
// support for double-quoted strings. Escape sequences inside quotes: \" and
// \\. Anything else after a backslash inside quotes is treated literally.
func tokenizeBatchLine(s string) ([]string, error) {
var tokens []stringView on GitHub (pinned to 71377f2769)
Solutions
- Change the subcommand to `add`, `remove`, or `rm` on the reported line.
- Move read-only dependency queries out of the batch script (use `bd dep <id>` separately).
- Note `rm` is accepted as an alias for `remove`.
- Validate with `bd batch --dry-run` before executing.
Example fix
// before (batch file) dep remve bd-1 bd-2 // after dep remove bd-1 bd-2
Defensive patterns
Strategy: validation
Validate before calling
# Verify dep subcommands are only add/remove/rm:
awk '$1=="dep" && !(($2=="add")||($2=="remove")||($2=="rm")) { print "line " NR ": unknown dep subcommand: " $2 }' batch.txt Try / catch
if err := runBdBatch(file); err != nil {
if strings.Contains(err.Error(), "unknown dep subcommand") {
return fmt.Errorf("fix the dep subcommand; nothing was written: %w", err)
}
return err
} Prevention
- Remember `rm` is a valid alias for `remove`; no other subcommands exist in batch mode.
- Keep read commands (`dep list/show`) out of batch scripts.
- Dry-run every generated script before execution.
When it happens
Trigger: A batch line like `dep list bd-1`, `dep show bd-1`, or a misspelled `dep remve bd-1 bd-2` passed to `bd batch`.
Common situations: Users trying to query dependencies inside batch scripts; typos of remove/rm; scripts mixing read commands with write commands.
Related errors
- line %d: 'dep' requires a subcommand (add|remove)
- line %d: %w
- line %d: unsupported batch command %q (supported: close, upd
- unterminated quoted string
- parsing batch input: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/667675b93d570d5e.
Report an issue: GitHub.