hashicorp/nomad · error

Claim.AllocationID is required

Error message

Claim.AllocationID is required

What it means

Produced by ClientCSINodeExpandVolumeRequest.Validate() in client/structs/csi.go when req.Claim is non-nil but Claim.AllocationID is empty. Like the sibling checks, it exists to catch programmer error: every CSI volume claim must reference the allocation that holds it. It is joined with other validation errors via errors.Join.

Source

Thrown at client/structs/csi.go:492

}

func (req *ClientCSINodeExpandVolumeRequest) Validate() error {
	var err error
	// These should not occur during normal operations; they're here
	// mainly to catch potential programmer error.
	if req.PluginID == "" {
		err = errors.Join(err, errors.New("PluginID is required"))
	}
	if req.VolumeID == "" {
		err = errors.Join(err, errors.New("VolumeID is required"))
	}
	if req.ExternalID == "" {
		err = errors.Join(err, errors.New("ExternalID is required"))
	}
	if req.Claim == nil {
		err = errors.Join(err, errors.New("Claim is required"))
	} else if req.Claim.AllocationID == "" {
		err = errors.Join(err, errors.New("Claim.AllocationID is required"))
	}
	return err
}

type ClientCSINodeExpandVolumeResponse struct {
	CapacityBytes int64
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Set Claim.AllocationID to the ID of the allocation using the volume before validating
  2. Verify the claim object was hydrated from the server's CSIVolumeClaim state, not an empty stub
  3. Run Validate() only after the full claim lifecycle fields (AllocationID, NodeID, Mode) are populated

Example fix

// before
claim := &cstructs.CSIVolumeClaim{NodeID: nodeID, Mode: structs.CSIVolumeClaimMode}
// after
claim := &cstructs.CSIVolumeClaim{AllocationID: alloc.ID, NodeID: nodeID, Mode: structs.CSIVolumeClaimMode}
Defensive patterns

Strategy: validation

Validate before calling

if req.Claim == nil || req.Claim.AllocationID == "" {
	return fmt.Errorf("node expand requires a claim with AllocationID")
}

Type guard

func claimHasAllocation(c *structs.CSIVolumeClaim) bool {
	return c != nil && c.AllocationID != ""
}

Try / catch

if err := req.Validate(); err != nil {
	if strings.Contains(err.Error(), "Claim.AllocationID is required") {
		req.Claim.AllocationID = alloc.ID
	}
	return err
}

Prevention

When it happens

Trigger: Calling the CSI NodeExpandVolume client RPC with a Claim struct that was partially initialized — e.g. &CSIVolumeClaim{NodeID: ..., Mode: ...} — but where AllocationID was never set.

Common situations: Hand-constructed requests in tests or tooling; code that builds a claim from a partially-deserialized state where the allocation ID was lost; custom scheduler or plugin code deriving claims without an alloc context.

Related errors


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