SigNoz/signoz · error · basemodel.ApiError
couldn't prepare request: %w
Error message
couldn't prepare request: %w
What it means
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.
Source
Thrown at ee/query-service/app/api/cloudIntegrations.go:324
) (*ResponseType, *basemodel.ApiError) {
reqMethod := http.MethodGet
var reqBody io.Reader
if payload != nil {
reqMethod = http.MethodPost
bodyJson, err := json.Marshal(payload)
if err != nil {
return nil, basemodel.InternalError(fmt.Errorf(
"couldn't serialize request payload to JSON: %w", err,
))
}
reqBody = bytes.NewBuffer([]byte(bodyJson))
}
req, err := http.NewRequestWithContext(ctx, reqMethod, url, reqBody)
if err != nil {
return nil, basemodel.InternalError(fmt.Errorf(
"couldn't prepare request: %w", err,
))
}
for k, v := range headers {
req.Header.Set(k, v)
}
client := &http.Client{
Timeout: 10 * time.Second,
}
response, err := client.Do(req)
if err != nil {
return nil, basemodel.InternalError(fmt.Errorf("couldn't make request: %w", err))
}
defer response.Body.Close()View on GitHub (pinned to 5069bf80b0)
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
Defensive patterns
Strategy: validation
Validate before calling
u, err := url.Parse(rawURL)
if err != nil || (u.Scheme != "http" && u.Scheme != "https") || u.Host == "" {
return fmt.Errorf("invalid gateway URL: %q", rawURL)
} Try / catch
Validate the URL before building the request; fail with configuration context rather than the generic prepare error.
Prevention
- Validate cloud/gateway URLs at startup
- Fail fast on empty configured hosts
When it happens
Trigger: 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.
Common situations: Unset or misconfigured gateway base URL, a template producing 'https://.<empty-domain>', or copied URLs with stray characters.
Related errors
- gateway_unsupported
- couldn't serialize request payload to JSON: %w
- couldn't make request: %w
- couldn't read response: %w
- ErrCodeInvalidGatewayConfig
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/77abca24f4b7e279.
Report an issue: GitHub.