hashicorp/nomad · error

metadata keys must not be empty

Error message

metadata keys must not be empty

What it means

NodeMetaApplyRequest.Validate found an empty string key in the Meta map; metadata keys are used as interpolated HCL variables in constraints and must be non-empty (nil values unset keys, but keys themselves cannot be "").

Source

Thrown at nomad/structs/node.go:500

type NodeMetaApplyRequest struct {
	QueryOptions // Client RPCs must use QueryOptions to set AllowStale=true

	// NodeID is the node being targeted by this request (or the node
	// receiving this request if NodeID is empty).
	NodeID string

	// Meta is the new Node metadata being applied and differs slightly
	// from Node.Meta as nil values are used to unset Node.Meta keys.
	Meta map[string]*string
}

func (n *NodeMetaApplyRequest) Validate() error {
	if len(n.Meta) == 0 {
		return fmt.Errorf("missing required Meta object")
	}
	for k := range n.Meta {
		if k == "" {
			return fmt.Errorf("metadata keys must not be empty")
		}

		// Validate keys are dotted identifiers since their primary use case is in
		// constraints as interpolated hcl variables.
		// https://github.com/hashicorp/hcl/blob/v2.16.0/hclsyntax/spec.md#identifiers
		for part := range strings.SplitSeq(k, ".") {
			if !hclsyntax.ValidIdentifier(part) {
				return fmt.Errorf("%q is invalid; metadata keys must be valid dotted hcl identifiers", k)
			}
		}
	}

	return nil
}

// NodeMetaResponse is used to read Node metadata directly from Client agents.
type NodeMetaResponse struct {
	// Meta is the merged static + dynamic Node metadata

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Remove or rename empty metadata keys in the request
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nomad/structs/node.go:500 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/601e15d752183ed6. Report an issue: GitHub.