{"record":{"id":"8a5dca604d160e97","repo":"BoundaryML/baml","slug":"unsupported-type-checked-any-cannot-be-passed-as-inputs-to","errorCode":null,"errorMessage":"unsupported type: Checked[any] cannot be passed as inputs to baml functions","messagePattern":"unsupported type: Checked\\[any\\] cannot be passed as inputs to baml functions","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/serde/encode.go","lineNumber":127,"sourceCode":"\t\treturn &cffi.HostValue{\n\t\t\tValue: &cffi.HostValue_Handle{\n\t\t\t\tHandle: handle,\n\t\t\t},\n\t\t}, nil\n\t}\n\n\t// Check for custom serializers first using the original value (could be pointer or value)\n\tif serializer, ok := originalValue.(BamlSerializer); ok {\n\t\tencoded, err := serializer.Encode()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn encoded, nil\n\t}\n\n\tswitch concreteValue.(type) {\n\tcase shared.Checked[any]:\n\t\treturn nil, fmt.Errorf(\"unsupported type: Checked[any] cannot be passed as inputs to baml functions\")\n\tcase shared.StreamState[any]:\n\t\treturn nil, fmt.Errorf(\"unsupported type: StreamState[any] cannot be passed as inputs to baml functions\")\n\t}\n\n\t// Handle primitive kinds and collections using reflection value rv (points to underlying value)\n\tswitch rv.Kind() {\n\tcase reflect.String:\n\t\treturn &cffi.HostValue{\n\t\t\tValue: &cffi.HostValue_StringValue{\n\t\t\t\tStringValue: rv.String(),\n\t\t\t},\n\t\t}, nil\n\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn &cffi.HostValue{\n\t\t\tValue: &cffi.HostValue_IntValue{\n\t\t\t\tIntValue: rv.Int(),\n\t\t\t},","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/serde/encode.go#L109-L145","documentation":"The Go BAML client rejects shared.Checked[any] values as function inputs. Checked is a validation-result type produced by the runtime (wrapping a value plus validation errors); it exists only as an output/inspection type, so encodeValue refuses to serialize it as an argument.","triggerScenarios":"Assigning the result of a Checked-returning API (e.g. from b.InitChecked or parsing outputs) back into another baml function's parameters, or storing Checked values in a struct/class field passed to a baml function.","commonSituations":"Round-tripping outputs back as inputs; accidentally building a Checked value instead of its .Value/.Unchecked content; copying example code that passes validation wrappers around.","solutions":["Unwrap the Checked value to its underlying payload before passing it (use the value accessor it exposes)","Pass the raw struct/slice/string the Checked wraps instead","Restructure code so Checked values are only used for inspection, not as inputs"],"exampleFix":"// before\nchecked := baml.PrintStreamState(...) // types.Checked[any]\nb.Fn(ctx, checked) // rejected\n// after\nb.Fn(ctx, checked.Value)","handlingStrategy":"type-guard","validationCode":"func notChecked(v any) bool { return !isCheckedAny(v) }","typeGuard":"func isCheckedAny(v any) bool { return strings.Contains(reflect.TypeOf(v).String(), \"shared.Checked\") }","tryCatchPattern":"if err := b.Fn(ctx, in); err != nil {\n  if strings.Contains(err.Error(), \"Checked[any] cannot be passed\") { return ErrCheckedAsInput }\n  return err\n}","preventionTips":["Treat Checked as output-only; unwrap before reusing values as inputs","Keep a single conversion helper that sanitizes values before baml calls","Review struct fields for accidentally embedded Checked values"],"tags":["go","baml","type-restriction"],"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"}