{"record":{"id":"70fee59d3771d803","repo":"weaviate/weaviate","slug":"create-post-request-70fee5","errorCode":null,"errorMessage":"create POST request","messagePattern":"create POST request","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/text2vec-ollama/clients/ollama.go","lineNumber":79,"sourceCode":"\nfunc (v *ollama) vectorize(ctx context.Context, input []string,\n\tcfg moduletools.ClassConfig,\n) (*modulecomponents.VectorizationResult[[]float32], error) {\n\tsettings := ent.NewClassSettings(cfg)\n\tbody, err := json.Marshal(embeddingsRequest{\n\t\tModel: settings.Model(),\n\t\tInput: input,\n\t})\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"marshal body\")\n\t}\n\n\tendpointURL := v.urlBuilderFn(settings.ApiEndpoint())\n\n\treq, err := http.NewRequestWithContext(ctx, \"POST\", endpointURL,\n\t\tbytes.NewReader(body))\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"create POST request\")\n\t}\n\n\tres, err := v.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"send POST request\")\n\t}\n\tdefer res.Body.Close()\n\n\tbodyBytes, err := io.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"read response body\")\n\t}\n\n\treturn v.parseEmbeddingsResponse(res.StatusCode, bodyBytes, input)\n}\n\nfunc (v *ollama) parseEmbeddingsResponse(statusCode int,\n\tbodyBytes []byte, input []string,","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/modules/text2vec-ollama/clients/ollama.go#L61-L97","documentation":"This error is returned by the text2vec-ollama client when http.NewRequestWithContext fails to construct the POST request to the Ollama /api/embed endpoint (ollama.go:79). NewRequestWithContext only errors on an invalid HTTP method (never the case here, \"POST\" is hardcoded) or an unparsable URL, so in practice this wrapper almost always indicates a malformed apiEndpoint configured for the module. The error message is wrapped with pkg/errors so the underlying url.Parse error text is preserved in the chain.","triggerScenarios":"Occurs during vectorize (called from Vectorize and VectorizeQuery) when the configured apiEndpoint from class settings cannot be parsed as a URL — e.g. an empty string, \"localhost:11434\" without a scheme, containing spaces, or otherwise invalid URL characters. It fires synchronously before any network traffic is attempted.","commonSituations":"Users setting TEXT2VEC_OLLAMA_API_ENDPOINT or the per-class moduleConfig apiEndpoint to a host without the http:// or https:// scheme, leaving the setting empty, or copy-pasting an endpoint with a trailing space or stray character. Also seen when misconfiguring a custom Ollama proxy URL.","solutions":["Fix the apiEndpoint to include a full scheme and host, e.g. \"http://localhost:11434\".","Check the wrapped error text after 'create POST request:' — it names the exact URL parse failure (e.g. 'parse \"localhost:11434/api/embed\": missing protocol scheme').","Verify the value is set where you think it is: environment variable TEXT2VEC_OLLAMA_API_ENDPOINT vs per-class moduleConfig in the collection schema; class settings win.","If using Weaviate in Docker, remember localhost from inside the container is not the host; use http://host.docker.internal:11434 or the service name."],"exampleFix":"// before (invalid, no scheme)\n{\n  \"moduleConfig\": {\n    \"text2vec-ollama\": {\n      \"apiEndpoint\": \"localhost:11434\"\n    }\n  }\n}\n// after\n{\n  \"moduleConfig\": {\n    \"text2vec-ollama\": {\n      \"apiEndpoint\": \"http://localhost:11434\"\n    }\n  }\n}","handlingStrategy":"validation","validationCode":"func validateOllamaEndpoint(endpoint string) error {\n\tif endpoint == \"\" {\n\t\treturn fmt.Errorf(\"text2vec-ollama apiEndpoint is empty\")\n\t}\n\tu, err := url.Parse(endpoint)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid apiEndpoint %q: %w\", endpoint, err)\n\t}\n\tif u.Scheme != \"http\" && u.Scheme != \"https\" {\n\t\treturn fmt.Errorf(\"apiEndpoint %q must start with http:// or https://\", endpoint)\n\t}\n\tif u.Host == \"\" {\n\t\treturn fmt.Errorf(\"apiEndpoint %q is missing a host\", endpoint)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always specify the full URL including scheme and port: http://localhost:11434 or http://ollama:11434.","Validate the endpoint with the function above or a curl one-liner before creating collections with the module enabled.","Keep the endpoint in one place (env var or config template) rather than ad-hoc per-class values to avoid drift.","Remember class-level moduleConfig overrides the module-wide env var — check the schema if a fix 'doesn't take effect'."],"tags":["go","http","url-parse","configuration","weaviate-module"],"backgroundTag":"invalid-endpoint-url","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}