BoundaryML/baml · error
decodeRawObjectImpl is not set. Please call SetDecodeRawObje
Error message
decodeRawObjectImpl is not set. Please call SetDecodeRawObjectImpl() before using this function
What it means
decodeRawObject delegates to a pluggable implementation stored in _decodeRawObjectImpl, which must be registered via SetDecodeRawObjectImpl() during package init. If it is nil, the binding packages that register concrete decoders were never linked into the binary, so object decoding is unavailable.
Source
Thrown at engine/language_client_go/baml_go/raw_objects/utils.go:248
nilType := reflect.TypeOf((*nilObject)(nil)).Elem()
decodedValue, goType := serde.Decode(value, serde.NewInternalTypeMap(map[string]reflect.Type{
"INTERNAL.nil": nilType,
}))
if goType == nilType {
return nil, nil
}
return decodedValue.Interface(), nil
default:
panic("unexpected cffi.isCFFIObjectResponseSuccess_Result")
}
default:
panic("unexpected cffi.isCFFIObjectResponse_Response")
}
}
func decodeRawObject(rt unsafe.Pointer, cRaw *cffi.BamlObjectHandle) (RawPointer, error) {
if _decodeRawObjectImpl == nil {
return nil, fmt.Errorf("decodeRawObjectImpl is not set. Please call SetDecodeRawObjectImpl() before using this function")
}
raw, err := _decodeRawObjectImpl(rt, cRaw)
if err != nil {
return nil, err
}
// Log when Go receives an object from Rust
ffiLog("[CLIENT_GO_RECEIVE] type=%s ptr=0x%x", raw.ObjectType(), raw.pointer())
// on finalization, we need to call the destructor
runtime.SetFinalizer(raw, func(r RawPointer) {
ffiLog("[CLIENT_GO_DESTRUCTOR_START] type=%s ptr=0x%x", r.ObjectType(), r.pointer())
if err := destructor(r); err != nil {
// Always log errors (even if general logging disabled)
ffiLog("[CLIENT_GO_DESTRUCTOR_ERROR] type=%s ptr=0x%x error=%v", r.ObjectType(), r.pointer(), err)
} else {
ffiLog("[CLIENT_GO_DESTRUCTOR_OK] type=%s ptr=0x%x", r.ObjectType(), r.pointer())View on GitHub (pinned to bd85ce9dee)
Solutions
- Add the missing import that registers the decoder (e.g. _ "github.com/boundaryml/baml/engine/language_client_go/baml_go/runtime" in your main or client package)
- Update to a released baml_client entrypoint that performs the registration for you
- Ensure SetDecodeRawObjectImpl is called in an init() before any BAML call
- Pin/regenerate client code to match your baml_go version
Example fix
// before import "github.com/boundaryml/baml/engine/language_client_go/baml_go/raw_objects" // after import ( _ "github.com/boundaryml/baml/engine/language_client_go/baml_go/runtime" "github.com/boundaryml/baml/engine/language_client_go/baml_go/raw_objects" )
Defensive patterns
Strategy: validation
Validate before calling
if baml_decoders.Registered() == false { panic("decoder impl not registered: import the baml runtime package") } Prevention
- Always use the published baml_go client entrypoint which wires SetDecodeRawObjectImpl in init()
- Never import baml_go/raw_objects alone; add the blank import of the runtime glue package
- Run a smoke test that decodes one object at startup
When it happens
Trigger: decodeObjectResponse (via NewRawObject/CallMethod) runs in a binary where no decoder implementation was registered — typically because the required baml_go binding sub-package was not imported.
Common situations: Importing only baml_go/raw_objects without the glue package that calls SetDecodeRawObjectImpl (e.g. missing blank import of the runtime package), or upgrading baml_go and dropping a required import.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- panic(initErr)
- %w (library or dependency not found)
- invalid Go SDK import path `{import_path}`
- the Go generator requires `--sdk-import-path <MODULE>/baml_s
- failed to generate Go SDK: {error}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/b6cfc2f6676928b8.
Report an issue: GitHub.