{"record":{"id":"cec6f0bb5eeec606","repo":"BoundaryML/baml","slug":"unexpected-type-for-url-t","errorCode":null,"errorMessage":"unexpected type for URL: %T","messagePattern":"unexpected type for URL: %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_http_request.go","lineNumber":49,"sourceCode":"\t}\n\n\tid, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for ID: %T\", result)\n\t}\n\n\treturn id, nil\n}\n\nfunc (h *httpRequest) Url() (string, error) {\n\tresult, err := raw_objects.CallMethod(h, \"url\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get URL: %w\", err)\n\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}","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_http_request.go#L31-L67","documentation":"httpRequest.Url() expects the runtime 'url' method to return a Go string. 'unexpected type for URL: %T' means the bridge call succeeded but the returned value is not a string (nil, float64, struct, etc.).","triggerScenarios":"The runtime 'url' implementation returns a non-string — e.g. a URL object, nil for malformed requests, or a numeric value.","commonSituations":"Handlers returning URL objects instead of strings; scripts producing nil URLs for unmatched routes; cross-version schema drift.","solutions":["Fix the runtime/handler so 'url' returns a plain string","Check %T in the message to learn the actual type","If the value is a URL object, extract its string form on the runtime side","Align client and runtime versions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"u, err := req.Url()\nif err == nil && u == \"\" { log.Printf(\"warning: empty URL returned\") }","typeGuard":"func isString(v any) bool { _, ok := v.(string); return ok }","tryCatchPattern":"u, err := req.Url()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type\") {\n        return fmt.Errorf(\"runtime URL is not a string: %w\", err)\n    }\n    return err\n}","preventionTips":["Return plain string URLs from runtime handlers, not URL objects","Contract-test Url() string return","Align versions across client and runtime"],"tags":["go","type-mismatch","url"],"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"}