hashicorp/nomad · error

Failed to parse %s as time duration: %s

Error message

Failed to parse %s as time duration: %s

What it means

Config.ReadDuration parses a client option with time.ParseDuration; this error fires when the value exists but is not a valid Go duration string (e.g. "30" without a unit). Callers using ReadDurationDefault fall back to the default.

Source

Thrown at client/config/config.go:1056

// ReadIntDefault tries to parse the specified option as a int. If there is
// an error in parsing, the default option is returned.
func (c *Config) ReadIntDefault(id string, defaultValue int) int {
	val, err := c.ReadInt(id)
	if err != nil {
		return defaultValue
	}
	return val
}

// ReadDuration parses the specified option as a duration.
func (c *Config) ReadDuration(id string) (time.Duration, error) {
	val, ok := c.Options[id]
	if !ok {
		return time.Duration(0), fmt.Errorf("Specified config is missing from options")
	}
	dval, err := time.ParseDuration(val)
	if err != nil {
		return time.Duration(0), fmt.Errorf("Failed to parse %s as time duration: %s", val, err)
	}
	return dval, nil
}

// ReadDurationDefault tries to parse the specified option as a duration. If there is
// an error in parsing, the default option is returned.
func (c *Config) ReadDurationDefault(id string, defaultValue time.Duration) time.Duration {
	val, err := c.ReadDuration(id)
	if err != nil {
		return defaultValue
	}
	return val
}

// ReadStringListToMap tries to parse the specified option(s) as a comma separated list.
// If there is an error in parsing, an empty list is returned.
func (c *Config) ReadStringListToMap(keys ...string) map[string]struct{} {
	val := c.ReadAlternativeDefault(keys, "")

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Provide a valid duration like "30s" or "5m"
  2. Use ReadDurationDefault for tolerant parsing
  3. Validate durations at config load
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at client/config/config.go:1056 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


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