grafana/k6 · error

timeout must be greater than 0

Error message

timeout must be greater than 0

What it means

validateConfig() requires the url secret source's HTTP client timeout to be strictly positive. A zero or negative duration (including ones produced by '0s' or '-5s') fails startup immediately. Since newConfig() supplies a sane default, this error only appears when the timeout is explicitly overridden to a non-positive value.

Source

Thrown at internal/secretsource/url/url.go:583

		config = config.Apply(explicitCfg)
	}

	// Validate the final config
	if err := validateConfig(config); err != nil {
		return extConfig{}, err
	}

	return config, nil
}

func validateConfig(config extConfig) error {
	// Validate required fields and value constraints
	if err := validateURLTemplate(config.URLTemplate); err != nil {
		return err
	}

	if config.Timeout.Duration <= 0 {
		return errors.New("timeout must be greater than 0")
	}

	if config.RequestsPerMinuteLimit.Int64 <= 0 {
		return errors.New("requestsPerMinuteLimit must be greater than 0")
	}

	if config.RequestsBurst.Int64 <= 0 {
		return errors.New("requestsBurst must be greater than 0")
	}

	if config.MaxRetries.Int64 < 0 {
		return errors.New("maxRetries must be non-negative")
	}

	if config.RetryBackoff.Duration <= 0 {
		return errors.New("retryBackoff must be greater than 0")
	}

View on GitHub (pinned to 93accf6570)

Solutions

  1. Remove the timeout override so the built-in default applies
  2. Or set a positive value such as K6_SECRET_SOURCE_URL_TIMEOUT='30s'
  3. Scan the JSON config file and environment for 'timeout' entries set to 0 or negative durations

Example fix

# before
K6_SECRET_SOURCE_URL_TIMEOUT='0s'

# after
K6_SECRET_SOURCE_URL_TIMEOUT='30s'
Defensive patterns

Strategy: validation

Validate before calling

const t = Number(process.env.K6_SECRET_SOURCE_URL_TIMEOUT?.replace(/s$/, ''));
if (process.env.K6_SECRET_SOURCE_URL_TIMEOUT && t <= 0) {
  throw new Error('timeout must be > 0');
}

Prevention

When it happens

Trigger: Setting K6_SECRET_SOURCE_URL_TIMEOUT='0s' (or a negative duration), or a JSON/inline config with "timeout": "0s" / negative duration; the override survives the Apply() merge and fails validateConfig().

Common situations: Trying to disable the timeout by setting it to 0; unit tests that zero out all fields; a config file that enumerates every field with placeholder zeros.

Understand the failure class

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/63198f6c1a1de213. Report an issue: GitHub.