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, err

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Pass exactly one eval ID per invocation; loop over IDs in the shell for bulk deletes
  2. Use -filter instead of listing IDs to delete many evaluations matching a criteria
  3. 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

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


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/d3857d36eda57949. Report an issue: GitHub.