hashicorp/nomad · error

description longer than %d

Error message

description longer than %d

What it means

Namespace.Validate() enforces a maximum description length of maxNamespaceDescriptionLength = 256 characters. A longer Description field causes this error to be appended to the multierror returned from namespace create/update.

Source

Thrown at nomad/structs/structs.go:5663

	// Denied specifies the node pools that are not allowed to be used by jobs
	// in this namespace. This field supports wildcard globbing through the use
	// of `*` for multi-character matching. If specified, any node pool is
	// allowed to be used, except for those that match any of these patterns.
	// This field cannot be used with Allowed.
	Denied []string
}

func (n *Namespace) Validate() error {
	var mErr multierror.Error

	// Validate the name and description
	if !validNamespaceName.MatchString(n.Name) {
		err := fmt.Errorf("invalid name %q. Must match regex %s", n.Name, validNamespaceName)
		mErr.Errors = append(mErr.Errors, err)
	}
	if len(n.Description) > maxNamespaceDescriptionLength {
		err := fmt.Errorf("description longer than %d", maxNamespaceDescriptionLength)
		mErr.Errors = append(mErr.Errors, err)
	}

	err := n.NodePoolConfiguration.Validate()
	switch e := err.(type) {
	case *multierror.Error:
		for _, npErr := range e.Errors {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("invalid node pool configuration: %v", npErr))
		}
	case error:
		mErr.Errors = append(mErr.Errors, fmt.Errorf("invalid node pool configuration: %v", e))
	}

	err = n.VaultConfiguration.Validate()
	switch e := err.(type) {
	case *multierror.Error:
		for _, vErr := range e.Errors {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("invalid vault configuration: %v", vErr))

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Shorten the description to 256 characters or fewer
  2. Move long documentation into external docs or labels outside the namespace spec
  3. Truncate the description programmatically before calling the API
  4. Validate len(description) <= 256 in your IaC before apply

Example fix

// before
ns := &structs.Namespace{Description: strings.Repeat("x", 300)}
// after
desc := longDoc
if len(desc) > 256 { desc = desc[:256] }
ns := &structs.Namespace{Description: desc}
Defensive patterns

Strategy: validation

Validate before calling

const maxNamespaceDescriptionLength = 256
if len(desc) > maxNamespaceDescriptionLength {
    return fmt.Errorf("description is %d chars; limit is %d", len(desc), maxNamespaceDescriptionLength)
}

Prevention

When it happens

Trigger: Submitting a Namespace via `nomad namespace apply -description ...`, the /v1/namespaces HTTP API, or structs.Namespace.Validate where len(Description) > 256.

Common situations: Using long free-form documentation or markdown in the namespace description field; automated tooling that stuffs metadata into descriptions.

Related errors


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