{"record":{"id":"7c7babd68ca14cec","repo":"BoundaryML/baml","slug":"s-utils","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/raw_objects/utils.go","lineNumber":210,"sourceCode":"\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)\n\t\t\t\t}\n\t\t\t\tparsed[i] = decoded\n\t\t\t}\n\t\t\treturn parsed, nil\n\t\tcase *cffi.InvocationResponseSuccess_Value:","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/raw_objects/utils.go#L192-L228","documentation":"The FFI InvocationResponse carried an InvocationResponse_Error variant; the message is the raw error text from the CFFI layer (formatted with %s). This wraps any native-side failure that occurred while creating or invoking a BAML raw object, surfacing the underlying runtime error message verbatim.","triggerScenarios":"NewRawObject or CallMethod where the native runtime responds with *cffi.InvocationResponse_Error — e.g. the requested class/function does not exist or the native call failed.","commonSituations":"Referencing a BAML function/class name that does not exist in the loaded baml_client, version mismatch between generated client and runtime, or native-side argument errors.","solutions":["Read the wrapped message text — it names the actual native error","Verify the function/class name passed to NewRawObject/CallMethod exists in your BAML schema","Regenerate baml_client so generated code matches the installed runtime version","Fix the underlying cause reported by the native error (bad args, missing function, etc.)"],"exampleFix":"// before\nobj, err := baml.NewRawObject(rt, \"Classifiy\", args) // typo\n// after\nobj, err := baml.NewRawObject(rt, \"Classify\", args)","handlingStrategy":"try-catch","validationCode":"if !strings.Contains(schemaText, funcOrClassName) { return fmt.Errorf(\"%q not defined in BAML schema\", funcOrClassName) }","typeGuard":null,"tryCatchPattern":"obj, err := baml.NewRawObject(rt, name, args)\nif err != nil {\n  log.Printf(\"baml native error for %s: %v\", name, err)\n  return err\n}","preventionTips":["Spell-check class/function names against the .baml files","Regenerate the client after every schema edit","Log the full wrapped message — it names the native cause"],"tags":["go","ffi","wrapped-error"],"backgroundTag":"api-error-response","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"}