{"record":{"id":"ce242f1d0ad8d395","repo":"BoundaryML/baml","slug":"unexpected-type-for-method-t","errorCode":null,"errorMessage":"unexpected type for method: %T","messagePattern":"unexpected type for method: %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_http_request.go","lineNumber":63,"sourceCode":"\t}\n\n\turl, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for URL: %T\", result)\n\t}\n\n\treturn url, nil\n}\n\nfunc (h *httpRequest) Method() (string, error) {\n\tresult, err := raw_objects.CallMethod(h, \"method\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get method: %w\", err)\n\t}\n\n\tmethod, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for method: %T\", result)\n\t}\n\n\treturn method, nil\n}\n\nfunc (h *httpRequest) Headers() (map[string]string, error) {\n\tresult, err := raw_objects.CallMethod(h, \"headers\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get headers: %w\", err)\n\t}\n\n\theaders, ok := result.(map[string]string)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for headers: %T\", result)\n\t}\n\n\treturn headers, nil\n}","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_http_request.go#L45-L81","documentation":"Go type-assertion failure on an HTTP request proxy object: CallMethod('method') succeeded but returned a value that is not a Go string (the %T shows what came back). Like the sibling URL/headers accessors, this signals the bridge protocol returning an unexpected shape — usually a runtime/bindings version mismatch.","triggerScenarios":"The runtime's 'method' returns a non-string — for example nil when no method was set, or an enum/number in a custom implementation.","commonSituations":"Custom dispatchers storing the method as a number; scripts leaving method undefined; version drift in the request schema.","solutions":["Fix the runtime/handler so 'method' returns a string","Read %T to identify the actual type","Set an explicit method in the script/handler (e.g. 'GET')","Verify client/runtime version compatibility"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"m, err := req.Method()\nif err == nil && !validMethods[m] { log.Printf(\"unexpected method value: %q\", m) }","typeGuard":"func isString(v any) bool { _, ok := v.(string); return ok }","tryCatchPattern":"m, err := req.Method()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type\") {\n        return fmt.Errorf(\"runtime method is not a string: %w\", err)\n    }\n    return err\n}","preventionTips":["Store the HTTP method as a string in runtime handlers","Contract-test Method() output type","Pin versions together"],"tags":["go","type-mismatch","http-method"],"backgroundTag":"type-mismatch","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"}