weaviate/weaviate · error

create POST request

Error message

create POST request

What it means

After joining the URL, the client creates the outbound POST request to Contextual AI with http.NewRequestWithContext. This fails only for an invalid HTTP method or an unparsable target URL, and the failure is wrapped with 'create POST request'. Since the method is hardcoded to POST, in practice this means the joined URL is still invalid.

Source

Thrown at modules/reranker-contextualai/clients/ranker.go:162

	metadata := make([]string, len(documents))
	for i := range metadata {
		metadata[i] = ""
	}
	input.Metadata = metadata

	return input, nil
}

func (c *client) makeRankRequest(ctx context.Context, body []byte) (*http.Response, error) {
	contextualUrl, err := url.JoinPath(c.host, c.path)
	if err != nil {
		return nil, errors.Wrap(err, "join Contextual AI API host and path")
	}

	req, err := http.NewRequestWithContext(ctx, "POST", contextualUrl, bytes.NewReader(body))
	if err != nil {
		return nil, errors.Wrap(err, "create POST request")
	}

	apiKey, err := c.getApiKey(ctx)
	if err != nil {
		return nil, errors.Wrapf(err, "Contextual AI API Key")
	}

	req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", apiKey))
	req.Header.Add("Content-Type", "application/json")

	res, err := c.httpClient.Do(req)
	if err != nil {
		return nil, errors.Wrap(err, "send POST request")
	}

	return res, nil
}

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Fix the configured host so the joined URL is a valid absolute http(s) URL
  2. Validate the URL manually (e.g. url.Parse in a quick script) to see the exact parse error
  3. If using default settings, check for proxy env vars (HTTP_PROXY/HTTPS_PROXY) corruption is not the issue here — instead verify Weaviate build/config was not patched with a bad default path
  4. Read the wrapped inner error text; it pinpoints which part of the URL failed to parse
Defensive patterns

Strategy: validation

Validate before calling

if _, err := url.ParseRequestURI(joinedURL); err != nil {
    return fmt.Errorf("rerank URL invalid before request: %w", err)
}

Prevention

When it happens

Trigger: performRank -> makeRankRequest is called during a rerank query while the resolved Contextual AI URL is malformed (invalid host/path join result), so http.NewRequestWithContext returns an error constructing the request.

Common situations: Same root cause as the URL-join failure: a bad custom host override (missing scheme, invalid characters) in module configuration or environment; rarely a version change altering the default path constant.

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/d13e2ad3936dae52. Report an issue: GitHub.