{"record":{"id":"77abca24f4b7e279","repo":"SigNoz/signoz","slug":"couldn-t-prepare-request-w","errorCode":null,"errorMessage":"couldn't prepare request: %w","messagePattern":"couldn't prepare request: %w","errorType":"http","errorClass":"basemodel.ApiError","httpStatus":500,"severity":"error","filePath":"ee/query-service/app/api/cloudIntegrations.go","lineNumber":324,"sourceCode":") (*ResponseType, *basemodel.ApiError) {\n\n\treqMethod := http.MethodGet\n\tvar reqBody io.Reader\n\tif payload != nil {\n\t\treqMethod = http.MethodPost\n\n\t\tbodyJson, err := json.Marshal(payload)\n\t\tif err != nil {\n\t\t\treturn nil, basemodel.InternalError(fmt.Errorf(\n\t\t\t\t\"couldn't serialize request payload to JSON: %w\", err,\n\t\t\t))\n\t\t}\n\t\treqBody = bytes.NewBuffer([]byte(bodyJson))\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, reqMethod, url, reqBody)\n\tif err != nil {\n\t\treturn nil, basemodel.InternalError(fmt.Errorf(\n\t\t\t\"couldn't prepare request: %w\", err,\n\t\t))\n\t}\n\n\tfor k, v := range headers {\n\t\treq.Header.Set(k, v)\n\t}\n\n\tclient := &http.Client{\n\t\tTimeout: 10 * time.Second,\n\t}\n\n\tresponse, err := client.Do(req)\n\tif err != nil {\n\t\treturn nil, basemodel.InternalError(fmt.Errorf(\"couldn't make request: %w\", err))\n\t}\n\n\tdefer response.Body.Close()","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/ee/query-service/app/api/cloudIntegrations.go#L306-L342","documentation":"http.NewRequestWithContext rejected the request line — almost always a malformed URL (unsupported scheme, control characters, or an unparseable URL string) since the method is a constant. Wrapped as an internal error by the gateway request helper.","triggerScenarios":"requestAndParseResponse builds a request from a URL that net/http cannot parse: empty or non-http(s) scheme, whitespace/control chars, or a URL assembled from empty config values.","commonSituations":"Unset or misconfigured gateway base URL, a template producing 'https://.<empty-domain>', or copied URLs with stray characters.","solutions":["Log the exact URL being requested","Fix the gateway/cloud URL configuration so it is a valid absolute http(s) URL","Add a startup or pre-call url.Parse sanity check"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"u, err := url.Parse(rawURL)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\") || u.Host == \"\" {\n    return fmt.Errorf(\"invalid gateway URL: %q\", rawURL)\n}","typeGuard":null,"tryCatchPattern":"Validate the URL before building the request; fail with configuration context rather than the generic prepare error.","preventionTips":["Validate cloud/gateway URLs at startup","Fail fast on empty configured hosts"],"tags":["http-client","url","gateway","configuration"],"backgroundTag":"invalid-url","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}