{"record":{"id":"76c1fdaefbf58d64","repo":"grafana/k6","slug":"invalid-url-scheme","errorCode":null,"errorMessage":"invalid URL scheme","messagePattern":"invalid URL scheme","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/lib/trace/otel.go","lineNumber":31,"sourceCode":"\t\"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp\"\n\t\"go.opentelemetry.io/otel/sdk/resource\"\n\tsdktrace \"go.opentelemetry.io/otel/sdk/trace\"\n\tsemconv \"go.opentelemetry.io/otel/semconv/v1.20.0\"\n\t\"go.opentelemetry.io/otel/trace\"\n\t\"go.opentelemetry.io/otel/trace/noop\"\n\n\t\"go.k6.io/k6/v2/internal/lib/strvals\"\n)\n\nconst serviceName = \"k6\"\n\nvar (\n\t// ErrInvalidTracesOutput indicates that the defined traces output is not valid.\n\tErrInvalidTracesOutput = errors.New(\"invalid traces output\")\n\t// ErrInvalidProto indicates that the defined exporter protocol is not valid.\n\tErrInvalidProto = errors.New(\"invalid protocol\")\n\t// ErrInvalidURLScheme indicates that the defined exporter URL scheme is not valid.\n\tErrInvalidURLScheme = errors.New(\"invalid URL scheme\")\n\t// ErrInvalidGRPCWithURLPath indicates that an exporter using gRPC protocol does not support URL path.\n\tErrInvalidGRPCWithURLPath = errors.New(\"grpc protocol does not support URL path\")\n)\n\ntype (\n\ttracerProvShutdownFunc func(ctx context.Context) error\n)\n\n// TracerProvider provides methods for tracers initialization and shutdown of the\n// processing pipeline.\ntype TracerProvider struct {\n\ttrace.TracerProvider\n\tshutdown tracerProvShutdownFunc\n}\n\ntype tracerProviderParams struct {\n\tproto    string\n\tendpoint string","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/lib/trace/otel.go#L13-L49","documentation":"When a URL is given in the traces output line (otel=<url>), params.parseURL requires an explicit http:// or https:// scheme; the scheme also selects the http transport and insecure mode. url.Parse of a bare host:port/path yields an empty scheme, which triggers ErrInvalidURLScheme. The error message includes the offending scheme.","triggerScenarios":"--traces-output=otel=127.0.0.1:4318/v1/traces (no scheme, so u.Scheme is ''); non-http(s) schemes like otel=grpc://collector:4317 or otel=unix:///tmp/sock.","commonSituations":"Writing the endpoint the way OTel collector configs or grpc targets look (host:port without scheme); assuming the scheme is optional as it is in some other tools.","solutions":["Prefix the URL with http:// or https://, e.g. otel=http://127.0.0.1:4318/v1/traces","Use https:// when the collector is TLS-secured (insecure is then false)","For a plain grpc endpoint without a path, omit the URL and use defaults or proto=grpc"],"exampleFix":"# before\nk6 run --traces-output='otel=127.0.0.1:4318/v1/traces,proto=http' script.js\n# after\nk6 run --traces-output='otel=http://127.0.0.1:4318/v1/traces,proto=http' script.js","handlingStrategy":"validation","validationCode":"// Shell: require an explicit scheme in the URL part\nurl_part=\"$(echo \"$TRACES_OUTPUT\" | sed -n 's/^otel=\\([^,]*\\).*/\\1/p')\"\ncase \"$url_part\" in\n  http://*|https://*) ;;\n  \"\") ;;\n  *) echo \"traces URL must start with http:// or https://\" >&2; exit 1 ;;\nesac","typeGuard":"function hasHttpScheme(u) {\n  return /^https?:\\/\\//.test(u);\n}","tryCatchPattern":null,"preventionTips":["Always write the full URL including scheme in otel=<url> (http://host:4318/v1/traces)","Remember a bare host:port is not a valid URL for the traces output","Use https:// for TLS collectors; the scheme also controls the insecure setting"],"tags":["tracing","opentelemetry","url","configuration","k6"],"backgroundTag":"invalid-url-scheme","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}