hashicorp/nomad · error

missing TargetPath

Error message

missing TargetPath

What it means

NodePublishVolumeRequest.Validate requires TargetPath, the filesystem path inside the allocation where the volume will be mounted. An empty TargetPath means the plugin has no destination to bind-mount the external volume to, so the request is rejected. This prevents publishing a volume without a mount point.

Source

Thrown at plugins/csi/plugin.go:183

	return &csipbv1.NodePublishVolumeRequest{
		VolumeId:          r.ExternalID,
		PublishContext:    r.PublishContext,
		StagingTargetPath: r.StagingTargetPath,
		TargetPath:        r.TargetPath,
		VolumeCapability:  r.VolumeCapability.ToCSIRepresentation(),
		Readonly:          r.Readonly,
		Secrets:           r.Secrets,
		VolumeContext:     r.VolumeContext,
	}
}

func (r *NodePublishVolumeRequest) Validate() error {
	if r.ExternalID == "" {
		return errors.New("missing volume ID")
	}

	if r.TargetPath == "" {
		return errors.New("missing TargetPath")
	}

	if r.VolumeCapability == nil {
		return errors.New("missing VolumeCapabilities")
	}

	return nil
}

type NodeStageVolumeRequest struct {
	// The external ID of the volume to stage.
	ExternalID string

	// If the volume was attached via a call to `ControllerPublishVolume` then
	// we need to provide the returned PublishContext here.
	PublishContext map[string]string

	// The path to which the volume MAY be staged. It MUST be an

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Add `destination` to each volume_mount block in the job's task/group and resubmit: volume_mount { volume = "data", destination = "/mnt/data" }
  2. Upgrade the Nomad client/plugins so mount paths are derived correctly
  3. If constructing requests in Go, set TargetPath before calling Validate
  4. Inspect `nomad job inspect` output to confirm the rendered volume_mount destinations are present

Example fix

// before (HCL)
volume_mount {
  volume = "data"
}

// after (HCL)
volume_mount {
  volume      = "data"
  destination = "/mnt/data"
}
Defensive patterns

Strategy: validation

Validate before calling

if req.TargetPath == "" {
    return fmt.Errorf("TargetPath is required")
}

Try / catch

if err := req.Validate(); err != nil {
    if strings.Contains(err.Error(), "missing TargetPath") {
        return fmt.Errorf("volume_mount destination missing in job spec: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: A CSI NodePublishVolume call where r.TargetPath == "" — usually a job's volume_mount block missing the destination, or Nomad's mount point derivation failing so an empty path is passed to the plugin.

Common situations: Job spec `volume_mount { volume = "..." }` without a `destination`; template-generated jobs dropping the destination field; custom controllers building publish requests without the target path; CSI plugin version mismatch with an older Nomad client.

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/0a1f692b42780934. Report an issue: GitHub.