{"record":{"id":"d13e2ad3936dae52","repo":"weaviate/weaviate","slug":"create-post-request-d13e2a","errorCode":null,"errorMessage":"create POST request","messagePattern":"create POST request","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/reranker-contextualai/clients/ranker.go","lineNumber":162,"sourceCode":"\n\tmetadata := make([]string, len(documents))\n\tfor i := range metadata {\n\t\tmetadata[i] = \"\"\n\t}\n\tinput.Metadata = metadata\n\n\treturn input, nil\n}\n\nfunc (c *client) makeRankRequest(ctx context.Context, body []byte) (*http.Response, error) {\n\tcontextualUrl, err := url.JoinPath(c.host, c.path)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"join Contextual AI API host and path\")\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, \"POST\", contextualUrl, bytes.NewReader(body))\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"create POST request\")\n\t}\n\n\tapiKey, err := c.getApiKey(ctx)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"Contextual AI API Key\")\n\t}\n\n\treq.Header.Add(\"Authorization\", fmt.Sprintf(\"Bearer %s\", apiKey))\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tres, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"send POST request\")\n\t}\n\n\treturn res, nil\n}\n","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/modules/reranker-contextualai/clients/ranker.go#L144-L180","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the configured host so the joined URL is a valid absolute http(s) URL","Validate the URL manually (e.g. url.Parse in a quick script) to see the exact parse error","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","Read the wrapped inner error text; it pinpoints which part of the URL failed to parse"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if _, err := url.ParseRequestURI(joinedURL); err != nil {\n    return fmt.Errorf(\"rerank URL invalid before request: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the final request URL with url.ParseRequestURI before issuing requests","Keep default host/path unless overriding deliberately; document any override"],"tags":["http","url","reranker","contextual-ai"],"backgroundTag":"invalid-url","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}