{"record":{"id":"9e32b6fa6e70d705","repo":"BoundaryML/baml","slug":"nil-response","errorCode":null,"errorMessage":"nil response","messagePattern":"nil response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/raw_objects/utils.go","lineNumber":205,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal content bytes: %w\", err)\n\t}\n\n\tparsed, err := decodeObjectResponse(object.Runtime(), &content_holder)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode object response: %w\", err)\n\t}\n\n\treturn parsed, nil\n}\n\ntype nilObject struct {\n\tany\n}\n\nfunc decodeObjectResponse(rt unsafe.Pointer, response *cffi.InvocationResponse) (any, error) {\n\tif response == nil {\n\t\treturn nil, fmt.Errorf(\"nil response\")\n\t}\n\n\tswitch response.GetResponse().(type) {\n\tcase *cffi.InvocationResponse_Error:\n\t\treturn nil, fmt.Errorf(\"%s\", response.GetError())\n\tcase *cffi.InvocationResponse_Success:\n\t\tsuccess := response.GetSuccess()\n\t\tswitch success.Result.(type) {\n\t\tcase *cffi.InvocationResponseSuccess_Object:\n\t\t\tobject := success.GetObject()\n\t\t\treturn decodeRawObject(rt, object)\n\t\tcase *cffi.InvocationResponseSuccess_Objects:\n\t\t\tobjects := success.GetObjects()\n\t\t\tparsed := make([]RawPointer, len(objects.Objects))\n\t\t\tfor i, obj := range objects.Objects {\n\t\t\t\tdecoded, err := decodeRawObject(rt, obj)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"failed to decode object at index %d: %w\", i, err)","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/raw_objects/utils.go#L187-L223","documentation":"decodeObjectResponse received a nil *cffi.InvocationResponse pointer. The library requires a populated FFI invocation response to decode a raw BAML object; a nil pointer means the C bridge returned nothing at all, so decoding cannot proceed. This is an internal contract violation between the Go bindings and the C/CFFI layer rather than a user-facing error.","triggerScenarios":"NewRawObject or CallMethod invoked with a response pointer that is nil, i.e. the cffi runtime produced no InvocationResponse for the call.","commonSituations":"Corrupted or mismatched BAML native library installation, a failed FFI initialization that silently returns null, or calling functions before the runtime is properly initialized.","solutions":["Reinstall / rebuild the BAML Go bindings so the native cffi library matches your baml_go version","Verify the BAML runtime is initialized (e.g. BAML log/ensure initialized) before calling NewRawObject or CallMethod","Check the FFI call site that produced the nil response for earlier errors that were swallowed","Report to BAML maintainers with a minimal repro if the runtime is healthy"],"exampleFix":"// before\nresp, _ := invoke()\nraw, err := decodeObjectResponse(rt, resp)\n// after\nresp, err := invoke()\nif err != nil { return err }\nif resp == nil { return fmt.Errorf(\"runtime returned nil invocation response\") }\nraw, err := decodeObjectResponse(rt, resp)","handlingStrategy":"type-guard","validationCode":"if resp == nil { return fmt.Errorf(\"no invocation response from BAML runtime\") }","typeGuard":"func hasResponse(r *cffi.InvocationResponse) bool { return r != nil && r.GetResponse() != nil }","tryCatchPattern":"raw, err := decodeObjectResponse(rt, resp)\nif err != nil {\n  return fmt.Errorf(\"baml object decode failed: %w\", err)\n}","preventionTips":["Always import the full baml client entrypoint, not internal packages directly","Check errors from every FFI call before decoding","Keep baml_go bindings and native library versions in lockstep"],"tags":["go","ffi","decoding"],"backgroundTag":"unexpected-response-shape","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}