hashicorp/nomad · warning

missing targetPath

Error message

missing targetPath

What it means

NodeUnpublishVolume rejects an empty targetPath argument before any gRPC call. Like the missing-volumeID check, this is a development aid to catch internal callers passing incomplete unpublish requests.

Source

Thrown at plugins/csi/client.go:899

				req.ExternalID, err)
		case codes.Internal:
			err = fmt.Errorf("node plugin returned an internal error, check the plugin allocation logs for more information: %v", err)
		}
	}
	return err
}

func (c *client) NodeUnpublishVolume(ctx context.Context, volumeID, targetPath string, opts ...grpc.CallOption) error {
	if err := c.ensureConnected(ctx); err != nil {
		return err
	}
	// These errors should not be returned during production use but exist as aids
	// during Nomad development
	if volumeID == "" {
		return fmt.Errorf("missing volumeID")
	}
	if targetPath == "" {
		return fmt.Errorf("missing targetPath")
	}

	req := &csipbv1.NodeUnpublishVolumeRequest{
		VolumeId:   volumeID,
		TargetPath: targetPath,
	}

	// NodeUnpublishVolume's response contains no extra data. If err == nil, we were
	// successful.
	_, err := c.nodeClient.NodeUnpublishVolume(ctx, req, opts...)
	if err != nil {
		code := status.Code(err)
		switch code {
		case codes.NotFound:
			err = fmt.Errorf("%w: volume %q could not be found: %v",
				structs.ErrCSIClientRPCIgnorable, volumeID, err)
		case codes.Internal:
			err = fmt.Errorf("node plugin returned an internal error, check the plugin allocation logs for more information: %v", err)

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Fix the caller to pass the allocation's CSI_TARGET_PATH (the mount path used during publish).
  2. Reconstruct the target path from the alloc dir layout if the record was lost (allocDir/alloc_mounts/...).
  3. In tests, provide a valid non-empty target path fixture.

Example fix

// before
c.NodeUnpublishVolume(ctx, volumeID, targetPath) // targetPath == ""
// after
targetPath := filepath.Join(allocDir, alloc.MountDir, "csi", volumeID)
if targetPath == "" { return fmt.Errorf("target path unresolved") }
return c.NodeUnpublishVolume(ctx, volumeID, targetPath)
Defensive patterns

Strategy: validation

Validate before calling

if targetPath == "" {
	return fmt.Errorf("cannot unpublish: target path is empty")
}

Prevention

When it happens

Trigger: Calling NodeUnpublishVolume(ctx, volumeID, "") — the targetPath string is empty.

Common situations: Task allocation lost its mount directory record; host path interpolation produced an empty string; a plugin/task runner bug cleared the target path before cleanup; tests calling with placeholder values.

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/35f9190cce018d08. Report an issue: GitHub.