hashicorp/nomad · error

failed to determine absolute path for %s

Error message

failed to determine absolute path for %s

What it means

storage_windows.go diskInfo() calls filepath.Abs(path) to resolve the host volume path into an absolute path before inspecting the filesystem. filepath.Abs only fails when Getwd fails or the path is unresolvable, so this wraps that rare OS-level failure. The error preserves the original relative path but drops the underlying error detail.

Source

Thrown at client/fingerprint/storage_windows.go:21

package fingerprint

import (
	"fmt"
	"path/filepath"
	"syscall"
)

//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zstorage_windows.go storage_windows.go

//sys	getDiskSpaceEx(dirName *uint16, availableFreeBytes *uint64, totalBytes *uint64, totalFreeBytes *uint64) (err error) = kernel32.GetDiskFreeSpaceExW

// diskInfo inspects the filesystem for path and returns the volume name and
// the total bytes available on the file system.
func (f *StorageFingerprint) diskInfo(path string) (volume string, total uint64, err error) {
	absPath, err := filepath.Abs(path)
	if err != nil {
		return "", 0, fmt.Errorf("failed to determine absolute path for %s", path)
	}

	volume = filepath.VolumeName(absPath)

	absPathp, err := syscall.UTF16PtrFromString(absPath)
	if err != nil {
		return "", 0, fmt.Errorf("failed to convert \"%s\" to UTF16: %v", absPath, err)
	}

	if err := getDiskSpaceEx(absPathp, nil, &total, nil); err != nil {
		return "", 0, fmt.Errorf("failed to get free disk space for %s: %v", absPath, err)
	}

	return volume, total, nil
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Start the Nomad client from a valid, existing working directory (or set one explicitly in the service definition)
  2. Verify the path string given to the fingerprint contains valid Windows path characters
  3. Check the underlying Getwd failure: ensure the process CWD exists and the user has permission to it
  4. Upgrade Nomad — newer versions propagate the wrapped error for easier diagnosis

Example fix

// before (library code, for context)
absPath, err := filepath.Abs(path)
if err != nil {
    return "", 0, fmt.Errorf("failed to determine absolute path for %s", path)
}
// after (if patching the library to keep the cause)
absPath, err := filepath.Abs(path)
if err != nil {
    return "", 0, fmt.Errorf("failed to determine absolute path for %s: %w", path, err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

if path == "" || strings.ContainsAny(path, "\x00") {
    return errors.New("storage fingerprint path is empty or contains NUL bytes")
}

Type guard

func isResolvablePath(p string) bool {
    abs, err := filepath.Abs(p)
    return err == nil && abs != ""
}

Try / catch

volume, total, err := fp.diskInfo(path)
if err != nil {
    if strings.Contains(err.Error(), "failed to determine absolute path") {
        log.Printf("skipping storage fingerprint: bad path %q (check CWD): %v", path, err)
        return nil // degrade gracefully
    }
    return err
}

Prevention

When it happens

Trigger: Fingerprinting a storage volume on Windows where filepath.Abs(path) returns an error — i.e. the current working directory has been deleted or is inaccessible so Getwd fails, or a malformed path reference cannot be resolved.

Common situations: Nomad client process started from a directory that was later removed; corrupted working directory on the Windows host; path passed to the storage fingerprint contains invalid characters preventing resolution.

Related errors


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