{"record":{"id":"d8e3f475c8baa6b2","repo":"BoundaryML/baml","slug":"unexpected-result-type-in-invocationresponse-t","errorCode":null,"errorMessage":"unexpected result type in InvocationResponse: %T","messagePattern":"unexpected result type in InvocationResponse: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/callbacks.go","lineNumber":253,"sourceCode":"\n\tswitch resp := response.GetResponse().(type) {\n\tcase *cffi.InvocationResponse_Error:\n\t\tsafeSend(callback.channel, ResultCallback{Error: BamlError{Message: resp.Error}})\n\tcase *cffi.InvocationResponse_Success:\n\t\tsuccess := resp.Success\n\t\tif success == nil {\n\t\t\tsafeSend(callback.channel, ResultCallback{Error: fmt.Errorf(\"nil success in InvocationResponse\")})\n\t\t} else {\n\t\t\tswitch result := success.GetResult().(type) {\n\t\t\tcase *cffi.InvocationResponseSuccess_Object:\n\t\t\t\tdecoded, decodeErr := decodeRawObjectImpl(callback.runtime, result.Object)\n\t\t\t\tif decodeErr != nil {\n\t\t\t\t\tsafeSend(callback.channel, ResultCallback{Error: fmt.Errorf(\"failed to decode object handle: %w\", decodeErr)})\n\t\t\t\t} else {\n\t\t\t\t\tsafeSend(callback.channel, ResultCallback{HasData: true, Data: decoded})\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tsafeSend(callback.channel, ResultCallback{Error: fmt.Errorf(\"unexpected result type in InvocationResponse: %T\", success.GetResult())})\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tsafeSend(callback.channel, ResultCallback{Error: fmt.Errorf(\"unexpected response type in InvocationResponse\")})\n\t}\n\n\tsafeClose(callback.channel)\n\tcallbackMutex.Lock()\n\tdefer callbackMutex.Unlock()\n\tdeleteCallback(id)\n}\n\nfunc create_unique_id(ctx context.Context, onTick OnTickCallbackData) (uint32, chan ResultCallback) {\n\tid := nextCallbackID.Add(1)\n\tcallbackMutex.Lock()\n\tdefer callbackMutex.Unlock()\n\tdynamicCallbacks[id] = CallbackData{channel: make(chan ResultCallback, 64), ctx: ctx, onTick: onTick, responseType: responseTypeValue}\n\tcallbackLog(\"[CLIENT_GO_CALLBACK_ADD] id=%d map_size=%d\", id, len(dynamicCallbacks))","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/callbacks.go#L235-L271","documentation":"If a successfully-decoded InvocationResponseSuccess contains neither an Object result nor any recognized result variant, the switch on success.GetResult() hits its default branch and reports the concrete Go type of the unexpected result. This guards the protocol: only known result kinds are accepted.","triggerScenarios":"The native runtime emits a newer/unknown InvocationResponseSuccess result variant (e.g. after a protocol extension) while the Go bindings are older, so the oneof resolves to an unrecognized case.","commonSituations":"Version skew between the baml CLI-generated native library and the Go cffi bindings; custom forks adding new result types.","solutions":["Upgrade the Go bindings to match the native runtime version (the %T in the message identifies the unknown variant).","Pin both sides to the same BAML release.","Search the BAML repo for the reported Go type to confirm it's a newer protocol addition.","File an issue if versions already match — indicates a decoder gap."],"exampleFix":"// before\ngo get github.com/boundaryml/baml@v0.8.0  # older bindings\n\n// after\ngo get github.com/boundaryml/baml@latest     # match native runtime version\ngo mod tidy","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"res := <-ch\nif res.Error != nil {\n\tif strings.Contains(res.Error.Error(), \"unexpected result type in InvocationResponse\") {\n\t\t// upgrade bindings to match native runtime, then retry once\n\t\treturn retryWithUpgradedBindings(ctx)\n\t}\n\treturn res.Error\n}","preventionTips":["Pin BAML Go bindings and native library to the same release","Watch release notes for new InvocationResponse result variants","Log the %T value when reporting issues"],"tags":["go","protobuf","ffi","version-mismatch"],"backgroundTag":"unexpected-api-response-shape","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"}