hashicorp/nomad · error

invalid name %q, must match regex %s

Error message

invalid name %q, must match regex %s

What it means

ValidateVaultClusterName: the Vault cluster name does not match the same regex used for Consul cluster names (validConsulVaultClusterName). Nomad CE supports only the default cluster name, and non-default names must be DNS-safe per the regex shown in the error.

Source

Thrown at nomad/structs/vault.go:18

// Copyright IBM Corp. 2015, 2026
// SPDX-License-Identifier: BUSL-1.1

package structs

import (
	"fmt"
)

const (
	// VaultDefaultCluster is the name used for the Vault cluster that doesn't
	// have a name.
	VaultDefaultCluster = "default"
)

func ValidateVaultClusterName(cluster string) error {
	if !validConsulVaultClusterName.MatchString(cluster) {
		return fmt.Errorf("invalid name %q, must match regex %s", cluster, validConsulVaultClusterName)
	}

	return nil
}

// GetVaultClusterName gets the Vault cluster for this task. Only a single
// default cluster is supported in Nomad CE, but this function can be safely
// used for ENT as well because the appropriate Cluster value will be set at the
// time of job submission.
func (t *Task) GetVaultClusterName() string {
	if t.Vault != nil && t.Vault.Cluster != "" {
		return t.Vault.Cluster
	}
	return VaultDefaultCluster
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Rename the cluster using only regex-compliant characters (alphanumerics, dashes)
  2. Check for typos, spaces, or slashes in the cluster name
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nomad/structs/vault.go:18 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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