hashicorp/nomad · error

missing node pool

Error message

missing node pool

What it means

Guard in NodePools.Register: the *NodePool argument is nil, so there is nothing to create or update; passing a nil pool is a client programming error.

Source

Thrown at api/node_pools.go:68

// Info is used to fetch details of a specific node pool.
func (n *NodePools) Info(name string, q *QueryOptions) (*NodePool, *QueryMeta, error) {
	if name == "" {
		return nil, nil, errors.New("missing node pool name")
	}

	var resp NodePool
	qm, err := n.client.query("/v1/node/pool/"+url.PathEscape(name), &resp, q)
	if err != nil {
		return nil, nil, err
	}
	return &resp, qm, nil
}

// Register is used to create or update a node pool.
func (n *NodePools) Register(pool *NodePool, w *WriteOptions) (*WriteMeta, error) {
	if pool == nil {
		return nil, errors.New("missing node pool")
	}
	if pool.Name == "" {
		return nil, errors.New("missing node pool name")
	}

	wm, err := n.client.put("/v1/node/pools", pool, nil, w)
	if err != nil {
		return nil, err
	}
	return wm, nil
}

// Delete is used to delete a node pool.
func (n *NodePools) Delete(name string, w *WriteOptions) (*WriteMeta, error) {
	if name == "" {
		return nil, errors.New("missing node pool name")
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Ensure a non-nil *NodePool is constructed (e.g. api.NewNodePool or &NodePool{Name: ...}) before Register
  2. Nil-check the pool at the call site and return a descriptive error
  3. Verify the config decode path actually populated the pool struct

Example fix

// before
var pool *api.NodePool // possibly nil
np.Register(pool, nil)
// after
if pool == nil {
    pool = &api.NodePool{Name: "default"}
}
np.Register(pool, nil)
Defensive patterns

Strategy: validation

Validate before calling

func poolOK(p *api.NodePool) bool { return p != nil }

Type guard

func nonNilPool(p *api.NodePool) (*api.NodePool, bool) {
    if p == nil { return nil, false }
    return p, true
}

Try / catch

if err := nodePools.Register(pool, nil); err != nil {
    return fmt.Errorf("register pool: %w", err)
}

Prevention

When it happens

Trigger: Calling n.Register(nil, w) directly, or a variable holding the pool that was never assigned after a failed unmarshal/parse step.

Common situations: Tools that build a NodePool conditionally and skip population; decoding a config section that was absent, yielding nil; copy-paste refactors dropping pool construction.

Related errors


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