hashicorp/nomad · error
LockNoPathErr
LockNoPathErr
Error message
variable's path can't be empty
What it means
Sentinel error LockNoPathErr returned when constructing a Lock whose Path field is empty. Nomad variables (and thus the locks built on them) are addressed by path, so an empty path leaves no key to lock.
Solutions
- Set the Variable's Path field before calling Locks, e.g. v.Path = "nomad/jobs/myjob/lock"
- Validate the path in configuration parsing and fail with a clear message early
- If the variable was loaded from a list result, refetch it by full path so Path is populated
Example fix
// before
v := api.Variable{Name: "lock"}
lock, err := c.Locks(wo, v)
// after
v := api.Variable{Name: "lock", Path: "nomad/jobs/myjob/lock"}
if v.Path == "" {
return errors.New("lock variable path is required")
}
lock, err := c.Locks(wo, v) Defensive patterns
Strategy: validation
Validate before calling
func lockVariableReady(v api.Variable) bool { return v.Path != "" } Try / catch
lock, err := c.Locks(wo, v)
if errors.Is(err, api.LockNoPathErr) {
return fmt.Errorf("lock variable %q has no path set", v.Name)
} Prevention
- Always populate Variable.Path before creating locks
- Validate path presence at config-parse time with a clear error
- Don't build locks from list-results; refetch the variable by full path
When it happens
Trigger: Calling c.Locks(wo, v, opts...) where v.Path == "", e.g. a Variable struct built from partial config or deserialized from a spec missing the path key.
Common situations: Config file with the lock variable declared but no 'path' attribute; programmatically constructed Variable structs where only the name was set; variable fetched by prefix/list instead of by path.
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
- job is missing ID
- ErrLockConflict
- Lock delay and TTL must be positive
- missing node pool
- missing node pool name
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/938a8e9b43d1c487.
Report an issue: GitHub.
Appendix: source
Thrown at api/locks.go:36
// DefaultLockTTL is the default value used to maintain a lock before it needs to
// be renewed. The actual value comes from the experience with Consul.
DefaultLockTTL = 15 * time.Second
// DefaultLockDelay is the default a lock will be blocked after the TTL
// went by without any renews. It is intended to prevent split brain situations.
// The actual value comes from the experience with Consul.
DefaultLockDelay = 15 * time.Second
)
var (
// ErrLockConflict is returned in case a lock operation can't be performed
// because the caller is not the current holder of the lock.
ErrLockConflict = errors.New("conflicting operation over lock")
//LockNoPathErr is returned when no path is provided in the variable to be
// used for the lease mechanism
LockNoPathErr = errors.New("variable's path can't be empty")
)
// Locks returns a new handle on a lock for the given variable.
func (c *Client) Locks(wo WriteOptions, v Variable, opts ...LocksOption) (*Locks, error) {
if v.Path == "" {
return nil, LockNoPathErr
}
ttl, err := time.ParseDuration(v.Lock.TTL)
if err != nil {
return nil, err
}
l := &Locks{
c: c,
WriteOptions: wo,
variable: v,View on GitHub (pinned to 482b49bf1a)