hashicorp/nomad · error

TargetPath is required

Error message

TargetPath is required

What it means

NodeExpandVolumeRequest.Validate in plugins/csi/plugin.go:1060 requires TargetPath, the filesystem path on the node where the volume is mounted, because CSI NodeExpandVolume operates on the published mount point. It is emitted (joined alongside any other failures) when TargetPath is empty.

Source

Thrown at plugins/csi/plugin.go:1060

		LimitBytes:    c.LimitBytes,
	}
}

type NodeExpandVolumeRequest struct {
	ExternalVolumeID string
	CapacityRange    *CapacityRange
	Capability       *VolumeCapability
	TargetPath       string
	StagingPath      string
}

func (r *NodeExpandVolumeRequest) Validate() error {
	var err error
	if r.ExternalVolumeID == "" {
		err = errors.Join(err, errors.New("ExternalVolumeID is required"))
	}
	if r.TargetPath == "" {
		err = errors.Join(err, errors.New("TargetPath is required"))
	}
	if e := r.CapacityRange.Validate(); e != nil {
		err = errors.Join(err, e)
	}
	return err
}

func (r *NodeExpandVolumeRequest) ToCSIRepresentation() *csipbv1.NodeExpandVolumeRequest {
	if r == nil {
		return nil
	}
	return &csipbv1.NodeExpandVolumeRequest{
		VolumeId:          r.ExternalVolumeID,
		VolumePath:        r.TargetPath,
		StagingTargetPath: r.StagingPath,
		CapacityRange:     r.CapacityRange.ToCSIRepresentation(),
		VolumeCapability:  r.Capability.ToCSIRepresentation(),
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Set TargetPath to the staging/publish mount path of the volume on that node (e.g. /var/lib/nomad/... mount point)
  2. Ensure the volume is actually published (an alloc is using it) before expanding; expansion requires a live mount
  3. Pass the path recorded in the volume's publish state rather than leaving it empty

Example fix

// before
err := client.NodeExpandVolume(volID, capacityRange, "")
// after
err := client.NodeExpandVolume(volID, capacityRange, mountPoint) // mountPoint from volume publish status
Defensive patterns

Strategy: validation

Validate before calling

if req.TargetPath == "" { return errors.New("TargetPath is required") }

Type guard

func hasTarget(req *csi.NodeExpandVolumeRequest) bool { return req.TargetPath != "" }

Prevention

When it happens

Trigger: Volume-expand request built without the path where the volume is published on the node; volume is not actually mounted/published so the caller has no target path and leaves it blank.

Common situations: Expanding a volume that was never mounted on the node (no alloc using it); custom CSI clients omitting TargetPath; automation that copies the create-request shape (which has no TargetPath) into an expand request.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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