hashicorp/nomad · error
expected 1 argument, got %v
Error message
expected 1 argument, got %v
What it means
verifyArgsAndFlags in eval_delete.go enforces that the user supplies exactly one argument (an eval ID) when no -filter is given, or zero arguments when -filter is given. Passing more than one positional argument fails with "expected 1 argument, got %v".
Source
Thrown at command/eval_delete.go:189
}
return exitCode
}
// verifyArgsAndFlags ensures the passed arguments and flags are valid for what
// this command accepts and can take action on.
func (e *EvalDeleteCommand) verifyArgsAndFlags(args []string) error {
numArgs := len(args)
// The command takes either an argument or filter, but not both.
if (e.filter == "" && numArgs < 1) || (e.filter != "" && numArgs > 0) {
return errors.New("evaluation ID or filter flag required")
}
// If an argument is supplied, we only accept a single eval ID.
if numArgs > 1 {
return fmt.Errorf("expected 1 argument, got %v", numArgs)
}
return nil
}
// handleEvalArgDelete handles deletion and evaluation which was passed via
// it's ID as a command argument. This is the simplest route to take and
// doesn't require filtering or batching.
func (e *EvalDeleteCommand) handleEvalArgDelete(evalID string) (int, error) {
evalInfo, _, err := e.client.Evaluations().Info(evalID, nil)
if err != nil {
return 1, err
}
// Supplying an eval to delete by its ID will always skip verification, so
// we don't need to understand the boolean response.
code, _, err := e.batchDelete([]*api.Evaluation{evalInfo})
return code, errView on GitHub (pinned to 482b49bf1a)
Solutions
- Pass exactly one eval ID per invocation; loop over IDs in the shell for bulk deletes
- Use -filter instead of listing IDs to delete many evaluations matching a criteria
- Quote arguments containing spaces so they count as a single arg
Example fix
// before nomad eval delete id1 id2 // after for id in id1 id2; do nomad eval delete "$id"; done # or nomad eval delete -filter 'JobID == "example"'
Defensive patterns
Strategy: validation
Validate before calling
if len(args) > 1 || (filter == "" && len(args) == 0) {
return fmt.Errorf("usage: nomad eval delete <eval-id> | nomad eval delete -filter <expr>")
} Prevention
- Delete one eval per invocation; loop for bulk operations
- Prefer -filter for bulk deletes
- Quote arguments so shell word-splitting doesn't create extra args
When it happens
Trigger: Running `nomad eval delete <id1> <id2>` or accidentally passing extra tokens (e.g. unquoted filter string splitting into multiple args).
Common situations: Trying to batch-delete multiple eval IDs in one command (unsupported); a shell word-splitting issue where a quoted expression became several arguments.
Related errors
- evaluation ID or filter flag required
- both -n and -c set
- no formatting option given
- Identifier must contain at least two characters.
- cannot give both an address and id
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/d3857d36eda57949.
Report an issue: GitHub.