hashicorp/nomad · error

invalid name '%s'

Error message

invalid name '%s'

What it means

Returned by JobAction.Validate in Nomad's structs package when a job action's Name does not match the validJobActionName regular expression. Job action names must follow Nomad's action naming convention (restricted character set/format); any name with disallowed characters, wrong casing, or invalid structure fails validation and is wrapped into the multierror returned to the API caller.

Source

Thrown at nomad/structs/actions.go:89

	if a == nil || o == nil {
		return false
	}
	return a.Name == o.Name &&
		a.Command == o.Command &&
		slices.Equal(a.Args, o.Args)
}

func (a *Action) Validate() error {
	if a == nil {
		return nil
	}

	var mErr *multierror.Error
	if a.Command == "" {
		mErr = multierror.Append(mErr, errors.New("command cannot be empty"))
	}
	if !validJobActionName.MatchString(a.Name) {
		mErr = multierror.Append(mErr, fmt.Errorf("invalid name '%s'", a.Name))
	}

	return mErr.ErrorOrNil()
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Rename the action to satisfy validJobActionName (lowercase alphanumeric segments joined by dashes/underscores, per the regexp).
  2. Run 'nomad job validate' locally before submitting to catch invalid names early.
  3. Update CI-generated job specs to sanitize/normalize action names.
  4. Review the Nomad docs for job actions naming rules.

Example fix

// before
actions {
  "my action" {
    command = "/bin/ls"
  }
}
// after
actions {
  "my-action" {
    command = "/bin/ls"
  }
}
Defensive patterns

Strategy: validation

Validate before calling

var validJobActionName = regexp.MustCompile(`^[a-zA-Z0-9_-]+$`)
if !validJobActionName.MatchString(action.Name) {
    return fmt.Errorf("action name %q is invalid; use alphanumerics, dashes or underscores", action.Name)
}

Try / catch

if err := job.Validate(); err != nil {
    if mErr, ok := err.(*multierror.Error); ok {
        for _, e := range mErr.Errors {
            if strings.Contains(e.Error(), "invalid name") {
                // fix offending action name and resubmit
            }
        }
    }
    return err
}

Prevention

When it happens

Trigger: Submitting a job (jobs/register or nomad job run) whose task-level actions block contains an action with a name failing validJobActionName, e.g. containing spaces, slashes, or empty-adjacent invalid characters.

Common situations: Hand-written HCL/JSON jobs with action names like "my action" or "run/app"; templating that injects un-validated names; upgrading Nomad to a version that introduced actions validation on previously lenient job specs.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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