hashicorp/nomad · error

evaluation ID or filter flag required

Error message

evaluation ID or filter flag required

What it means

`nomad eval delete` requires exactly one selector: either an evaluation ID argument or the -filter flag, never both and never neither. verifyArgsAndFlags returns this error when both are absent (nothing to delete) or when an ID plus -filter are both supplied.

Source

Thrown at command/eval_delete.go:184

	if e.numDeleted > 0 {
		e.Ui.Output(fmt.Sprintf("Successfully deleted %v %s",
			e.numDeleted, correctGrammar("evaluation", e.numDeleted)))
	} else if err == nil {
		e.Ui.Output("No evaluations were deleted")
	}

	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
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Pass exactly one: `nomad eval delete <eval-id>` or `nomad eval delete -filter 'JobID == "web"'`.
  2. In scripts, branch on whether the ID is known: supply the ID alone, or the -filter alone.
  3. Check `nomad eval list` to obtain eval IDs if you meant to delete by ID.

Example fix

// before
$ nomad eval delete abc123 -filter 'JobID == "web"'
// after
$ nomad eval delete abc123        # OR
$ nomad eval delete -filter 'JobID == "web"'
Defensive patterns

Strategy: validation

Validate before calling

if (evalID == "" && filter == "") || (evalID != "" && filter != "") {
    return errors.New("supply exactly one of eval ID or -filter")
}

Try / catch

if err := evalDelete(); err != nil && strings.Contains(err.Error(), "evaluation ID or filter flag required") {
    fmt.Fprintln(os.Stderr, "pass either an eval ID or -filter, not both/neither")
    os.Exit(1)
}

Prevention

When it happens

Trigger: Running `nomad eval delete` with no arguments and no -filter, or with an eval ID argument AND -filter at the same time.

Common situations: Scripts that append -filter unconditionally while also passing an ID; users unsure of the delete-by-filter feature; copy-paste of combined examples.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


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