{"record":{"id":"2a9f4ac881b747f0","repo":"grafana/k6","slug":"create-new-http-request-failed-w","errorCode":null,"errorMessage":"create new HTTP request failed: %w","messagePattern":"create new HTTP request failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/output/prometheusrw/remote/client.go","lineNumber":86,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\twc.hc.Transport = tripper\n\t}\n\treturn wc, nil\n}\n\n// Store sends a batch of samples to the HTTP endpoint,\n// the request is the proto marshaled and encoded.\nfunc (c *WriteClient) Store(ctx context.Context, series []*prompb.TimeSeries) error {\n\tb, err := newWriteRequestBody(series)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq, err := http.NewRequestWithContext(\n\t\tctx, http.MethodPost, c.url.String(), bytes.NewReader(b))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create new HTTP request failed: %w\", err)\n\t}\n\tif c.cfg.BasicAuth != nil {\n\t\treq.SetBasicAuth(c.cfg.BasicAuth.Username, c.cfg.BasicAuth.Password)\n\t}\n\n\tif len(c.cfg.Headers) > 0 {\n\t\treq.Header = c.cfg.Headers.Clone()\n\t}\n\n\treq.Header.Set(\"User-Agent\", \"k6-prometheus-rw-output\")\n\n\t// They are mostly defined by the specs\n\treq.Header.Set(\"Content-Encoding\", \"snappy\")\n\treq.Header.Set(\"Content-Type\", \"application/x-protobuf\")\n\treq.Header.Set(\"X-Prometheus-Remote-Write-Version\", \"0.1.0\")\n\n\tresp, err := c.hc.Do(req) //nolint:gosec\n\tif err != nil {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/output/prometheusrw/remote/client.go#L68-L104","documentation":"Store failed to construct the outgoing HTTP request object for the Prometheus remote-write batch. http.NewRequestWithContext only errors when the URL is malformed or the method is invalid, so this fires at request-build time before any network I/O — the write client was initialized with a URL that cannot be parsed into a request.","triggerScenarios":"Thrown at internal/output/prometheusrw/remote/client.go:86 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the --out prometheus-rw=url value to a valid URL, e.g. http://prometheus:9090/api/v1/write","Check for control characters or whitespace in the URL"],"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-14T00:17:10.932Z"}