grafana/k6 · error

invalid %s: %w

Error message

invalid %s: %w

What it means

parseIntOption parses numeric options (requestsPerMinuteLimit, requestsBurst, maxRetries) with fmt.Sscanf("%d") and wraps any parse failure as "invalid <optionName>: ...". It means the value for that option was not a plain integer (e.g. "ten" or "1.5"), rejecting the secret source configuration.

Source

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

	case "requestsPerMinuteLimit":
		return parseIntOption(value, &cfg.RequestsPerMinuteLimit, "requestsPerMinuteLimit")
	case "requestsBurst":
		return parseIntOption(value, &cfg.RequestsBurst, "requestsBurst")
	case "maxRetries":
		return parseIntOption(value, &cfg.MaxRetries, "maxRetries")
	case "retryBackoff":
		return parseDurationOption(value, &cfg.RetryBackoff, "retryBackoff")
	default:
		return parseHeaderOption(key, value, cfg)
	}
	return nil
}

func parseIntOption(value string, target *null.Int, optionName string) error {
	var intValue int64
	_, err := fmt.Sscanf(value, "%d", &intValue)
	if err != nil {
		return fmt.Errorf("invalid %s: %w", optionName, err)
	}
	*target = null.IntFrom(intValue)
	return nil
}

func parseDurationOption(value string, target *types.NullDuration, optionName string) error {
	duration, err := time.ParseDuration(value)
	if err != nil {
		return fmt.Errorf("invalid %s: %w", optionName, err)
	}
	*target = types.NullDurationFrom(duration)
	return nil
}

func parseHeaderOption(key, value string, cfg *extConfig) error {
	if !strings.HasPrefix(key, "headers.") {
		return fmt.Errorf("unknown configuration key: %q", key)
	}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Set the named option to a plain integer, e.g. maxRetries=3
  2. Remove unit suffixes or non-numeric characters from the value
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/secretsource/url/url.go:388 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/45ab76ad2745ee30. Report an issue: GitHub.