{"record":{"id":"438e1182ee3bd96e","repo":"weaviate/weaviate","slug":"read-response-body-438e11","errorCode":null,"errorMessage":"read response body","messagePattern":"read response body","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/generative-databricks/clients/databricks.go","lineNumber":117,"sourceCode":"\tapiKey, err := v.getApiKey(ctx)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"Databricks Token\")\n\t}\n\treq.Header.Add(v.getApiKeyHeaderAndValue(apiKey))\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\tif userAgent := modulecomponents.GetValueFromContext(ctx, \"X-Databricks-User-Agent\"); userAgent != \"\" {\n\t\treq.Header.Add(\"User-Agent\", userAgent)\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\tvar resBody generateResponse\n\tif err := json.Unmarshal(bodyBytes, &resBody); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse generative response (status %d): %w\", res.StatusCode, err)\n\t}\n\n\tif res.StatusCode != 200 || resBody.Error != nil {\n\t\treturn nil, v.getError(res.StatusCode, resBody.Error)\n\t}\n\n\tresponseParams := v.getResponseParams(resBody.Usage)\n\ttextResponse := resBody.Choices[0].Text\n\tif len(resBody.Choices) > 0 && textResponse != \"\" {\n\t\ttrimmedResponse := strings.Trim(textResponse, \"\\n\")\n\t\treturn &modulecapabilities.GenerateResponse{\n\t\t\tResult: &trimmedResponse,\n\t\t\tDebug:  debugInformation,","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/modules/generative-databricks/clients/databricks.go#L99-L135","documentation":"Wraps an io.ReadAll failure while draining the Databricks HTTP response body. After a successful HTTP exchange, the response stream could not be read to completion — usually a mid-stream disconnect, body already closed/consumed, or context cancellation during read. No parsed result is produced even though the server may have generated output.","triggerScenarios":"Databricks closes the connection while the body is streaming; an intermediary (LB/proxy) resets the connection; the request context is canceled mid-read; response body truncated by network issues.","commonSituations":"Long-running generations over unstable links; reverse proxies with aggressive read timeouts (nginx proxy_read_timeout); Databricks server-side timeouts on very large prompts; flaky VPN/egress.","solutions":["Check the inner error: 'unexpected EOF'/connection reset → retry; 'context canceled' → raise your client timeout.","Reduce prompt size / maxTokens so the response completes before any intermediary timeout.","Increase proxy/LB read timeouts (e.g. nginx proxy_read_timeout) between weaviate and Databricks.","Retry the request; these are typically transient.","Check Databricks workspace status for server-side stream failures."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go\n_, err := collection.Generate(ctx, prompt, nil)\nif err != nil && strings.Contains(err.Error(), \"read response body\") {\n    if errors.Is(err, io.ErrUnexpectedEOF) || strings.Contains(err.Error(), \"connection reset\") {\n        // transient — retry with backoff and a smaller maxTokens\n    }\n    if errors.Is(err, context.Canceled) {\n        // client gave up — increase client timeout instead of retrying\n    }\n}","preventionTips":["Raise intermediary read timeouts (nginx proxy_read_timeout, LB idle timeout) for long generations.","Bound response size via maxTokens so bodies finish streaming quickly.","Retry transient EOF/reset errors with exponential backoff.","Avoid very large single prompts; chunk batch-generate work."],"tags":["network","http","io","databricks","response-body"],"backgroundTag":"response-body-read-error","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}