{"record":{"id":"bbe660d52221d13f","repo":"grafana/k6","slug":"couldn-t-parse-cloud-logs-host-w","errorCode":null,"errorMessage":"couldn't parse cloud logs host %w","messagePattern":"couldn't parse cloud logs host %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cloudapi/logs.go","lineNumber":91,"sourceCode":"\t}\n\n\treturn ts\n}\n\nfunc labelsToLogrusFields(labels map[string]string) logrus.Fields {\n\tfields := make(logrus.Fields, len(labels))\n\n\tfor key, val := range labels {\n\t\tfields[key] = val\n\t}\n\n\treturn fields\n}\n\nfunc (c *Config) logtailConn(ctx context.Context, referenceID string, since time.Time) (*websocket.Conn, error) {\n\tu, err := url.Parse(c.LogsTailURL.String)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't parse cloud logs host %w\", err)\n\t}\n\n\tu.RawQuery = fmt.Sprintf(`query={test_run_id=\"%s\"}&start=%d`, referenceID, since.UnixNano())\n\n\theaders := make(http.Header)\n\theaders.Add(\"Authorization\", \"token \"+c.Token.String)\n\theaders.Add(\"X-K6testrun-Id\", referenceID)\n\n\tvar conn *websocket.Conn\n\terr = retry(sleeperFunc(time.Sleep), 3, 5*time.Second, 2*time.Minute, func() (err error) {\n\t\t// We don't need to close the http body or use it for anything until we want to actually log\n\t\t// what the server returned as body when it errors out\n\t\tconn, _, err = websocket.DefaultDialer.DialContext(ctx, u.String(), headers) //nolint:bodyclose\n\t\treturn err\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/cloudapi/logs.go#L73-L109","documentation":"Returned by logtailConn when the configured cloud logs tail URL (Config.LogsTailURL) cannot be parsed by url.Parse before opening the websocket log stream. This points to a malformed logs host in the cloud configuration.","triggerScenarios":"Thrown at cloudapi/logs.go:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the K6_CLOUD_LOGS_TAIL_URL (or equivalent) setting to a valid URL","Omit the setting to use the default cloud logs host derived from the base URL"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}