{"record":{"id":"73fa467e6e2bb597","repo":"BoundaryML/baml","slug":"failed-to-get-text-w","errorCode":null,"errorMessage":"failed to get text: %w","messagePattern":"failed to get text: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_http_body.go","lineNumber":30,"sourceCode":"\t*raw_objects.RawObject\n}\n\nfunc newHTTPBody(ptr int64, rt unsafe.Pointer) HTTPBody {\n\treturn &httpBody{raw_objects.FromPointer(ptr, rt)}\n}\n\nfunc (h *httpBody) ObjectType() cffi.BamlObjectType {\n\treturn cffi.BamlObjectType_OBJECT_HTTP_BODY\n}\n\nfunc (h *httpBody) pointer() int64 {\n\treturn h.RawObject.Pointer()\n}\n\nfunc (h *httpBody) Text() (string, error) {\n\tresult, err := raw_objects.CallMethod(h, \"text\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get text: %w\", err)\n\t}\n\n\ttext, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for text: %T\", result)\n\t}\n\n\treturn text, nil\n}\n\nfunc (h *httpBody) JSON() (any, error) {\n\tresult, err := raw_objects.CallMethod(h, \"json\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get JSON: %w\", err)\n\t}\n\n\treturn result, nil\n}","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_http_body.go#L12-L48","documentation":"httpBody.Text() fetches the HTTP response body as text via the 'text' bridge method. This error wraps any failure of that bridge call (disposed object, missing method, runtime exception); it is the wrapping variant before the string type assertion.","triggerScenarios":"Calling HttpBody.Text() when the bridge fails to invoke 'text' on the body object, e.g. the body was already consumed or the runtime object is stale.","commonSituations":"Reading the body twice in the runtime (streams are consumed); response object released before Text() is called; runtime binding version drift.","solutions":["Read the wrapped root error to identify the bridge failure","Avoid consuming the body before calling Text(); fetch once and cache the result","Re-obtain the http body object from a fresh response"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if h == nil || h.RawObject == nil { return \"\", errors.New(\"nil http body\") }","typeGuard":null,"tryCatchPattern":"text, err := body.Text()\nif err != nil {\n    return \"\", fmt.Errorf(\"body text unavailable: %w\", err)\n}","preventionTips":["Call Text() exactly once before the body is consumed","Do not hold http body handles after the response is released","Keep runtime and Go binding versions in sync"],"tags":["go","rpc","http","error-wrapping"],"backgroundTag":"type-mismatch","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}