grafana/k6 · error

the provided header (%s) does not respect the expected forma

Error message

the provided header (%s) does not respect the expected format <header key>:<value>

What it means

K6_PROMETHEUS_RW_HTTP_HEADERS contained an entry that doesn't split into exactly two colon-separated parts, so it cannot be interpreted as key:value. parseEnvs enforces the <header key>:<value> syntax.

Source

Thrown at internal/output/prometheusrw/remotewrite/config.go:313

	err := envconfig.Process("", &c, func(key string) (string, bool) {
		v, ok := env[key]
		return v, ok
	})
	if err != nil {
		return Config{}, err
	}

	// We don't rely on `envconfig` for headers, as we do use our own logic/syntax with
	// dynamically-defined header-associated environment variables.
	envHeaders := envMap(env, "K6_PROMETHEUS_RW_HEADERS_")
	maps.Copy(c.Headers, envHeaders)

	if headers, headersDefined := env["K6_PROMETHEUS_RW_HTTP_HEADERS"]; headersDefined {
		for kvPair := range strings.SplitSeq(headers, ",") {
			header := strings.Split(kvPair, ":")
			if len(header) != 2 {
				return c, fmt.Errorf("the provided header (%s) does not respect the expected format <header key>:<value>", kvPair)
			}
			c.Headers[header[0]] = header[1]
		}
	}

	return c, nil
}

// parseJSON parses the supplied JSON into a Config.
func parseJSON(data json.RawMessage) (Config, error) {
	var c Config
	err := json.Unmarshal(data, &c)
	return c, err
}

// parseArg parses the supplied string of arguments into a Config.
func parseArg(text string) (Config, error) {
	var c Config

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Format entries as key:value with exactly one colon separator, e.g. K6_PROMETHEUS_RW_HTTP_HEADERS="Authorization:Bearer token,X-Custom:yes"
  2. Remove entries with extra or missing colons
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/output/prometheusrw/remotewrite/config.go:313 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/db96e0d789ab665b. Report an issue: GitHub.