nats-io/nats-server · error

the path [%s] is not a directory

Error message

the path [%s] is not a directory

What it means

Directory JWT store path validation: the path exists but its mode is a regular file while a directory was required (dir=true), e.g. the resolver store path points at a file.

Source

Thrown at server/dirstore.go:60

		return _EMPTY_, errors.New("path is not specified")
	}

	abs, err := filepath.Abs(path)
	if err != nil {
		return _EMPTY_, fmt.Errorf("error parsing path [%s]: %v", abs, err)
	}

	var finfo os.FileInfo
	if finfo, err = os.Stat(abs); err != nil {
		if os.IsNotExist(err) {
			return _EMPTY_, fmt.Errorf("the path [%s] doesn't exist", abs)
		}
		return _EMPTY_, fmt.Errorf("error accessing path [%s]: %v", abs, err)
	}

	mode := finfo.Mode()
	if dir && mode.IsRegular() {
		return _EMPTY_, fmt.Errorf("the path [%s] is not a directory", abs)
	}

	if !dir && mode.IsDir() {
		return _EMPTY_, fmt.Errorf("the path [%s] is not a file", abs)
	}

	return abs, nil
}

// ValidateDirPath checks that the provided path exists and is a dir
func validateDirPath(path string) (string, error) {
	return validatePathExists(path, true)
}

// JWTChanged functions are called when the store file watcher notices a JWT changed
type JWTChanged func(publicKey string)

// DirJWTStore implements the JWT Store interface, keeping JWTs in an optionally sharded

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Point the store at a directory
  2. Remove the file blocking directory creation
  3. Fix the configuration value
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/dirstore.go:60 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02). Data as JSON: /api/errors/26ae256df8ea7856. Report an issue: GitHub.