{"record":{"id":"1302ab67fc384ef6","repo":"grafana/k6","slug":"failed-to-parse-headers-w","errorCode":null,"errorMessage":"failed to parse headers: %w","messagePattern":"failed to parse headers: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/output/opentelemetry/exporter.go","lineNumber":38,"sourceCode":"\t// ctx isn't used at any point in the exporter\n\t// later on, it could be used for the connection timeout\n\tctx := context.Background()\n\n\ttlsConfig, err := buildTLSConfig(\n\t\tcfg.TLSInsecureSkipVerify,\n\t\tcfg.TLSCertificate,\n\t\tcfg.TLSClientCertificate,\n\t\tcfg.TLSClientKey,\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\theaders := make(map[string]string)\n\tif cfg.Headers.Valid {\n\t\theaders, err = parseHeaders(cfg.Headers.String)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse headers: %w\", err)\n\t\t}\n\t}\n\n\t// if at least valid user was configured, use basic auth\n\tif cfg.HTTPUsername.Valid {\n\t\tauth := []byte(cfg.HTTPUsername.String + \":\" + cfg.HTTPPassword.String)\n\t\theaders[\"Authorization\"] = fmt.Sprintf(\"Basic %s\", base64.StdEncoding.EncodeToString(auth))\n\t}\n\n\tswitch cfg.ExporterProtocol.String {\n\tcase grpcExporterProtocol:\n\t\treturn buildGRPCExporter(ctx, cfg, tlsConfig, headers)\n\tcase httpExporterProtocol:\n\t\treturn buildHTTPExporter(ctx, cfg, tlsConfig, headers)\n\tdefault:\n\t\treturn nil, errors.New(\"unsupported exporter protocol \" + cfg.ExporterProtocol.String)\n\t}\n}","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/output/opentelemetry/exporter.go#L20-L56","documentation":"The OpenTelemetry output was configured with custom headers (K6_OTEL_HEADERS), and the header list could not be parsed into key=value pairs. getExporter wraps the parseHeaders failure while constructing the metric exporter.","triggerScenarios":"Thrown at internal/output/opentelemetry/exporter.go:38 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Format headers as comma-separated key=value pairs, e.g. K6_OTEL_HEADERS=key1=value1,key2=value2","Use percent-encoding for special characters in keys or values"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}