{"record":{"id":"78670e983beadbd6","repo":"BoundaryML/baml","slug":"unexpected-type-for-id-t-rawobjects-http-request","errorCode":null,"errorMessage":"unexpected type for ID: %T","messagePattern":"unexpected type for ID: %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_http_request.go","lineNumber":35,"sourceCode":"}\n\nfunc (h *httpRequest) ObjectType() cffi.BamlObjectType {\n\treturn cffi.BamlObjectType_OBJECT_HTTP_REQUEST\n}\n\nfunc (h *httpRequest) pointer() int64 {\n\treturn h.RawObject.Pointer()\n}\n\nfunc (h *httpRequest) RequestId() (string, error) {\n\tresult, err := raw_objects.CallMethod(h, \"id\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get ID: %w\", err)\n\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}","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_http_request.go#L17-L53","documentation":"httpRequest.RequestId() expects the runtime 'id' method to return a Go string. 'unexpected type for ID: %T' means the bridge succeeded but returned a different Go type (e.g. nil, float64, map), so the value cannot be safely returned as a string.","triggerScenarios":"The runtime's 'id' implementation returns a non-string (null, number, object) — e.g. a custom handler or script returning a numeric or absent ID.","commonSituations":"Custom request handlers/scripts that omit or redefine 'id'; schema changes in the runtime where IDs became numbers; serialization converting the ID type.","solutions":["Fix the runtime/handler so 'id' returns a string","Inspect %T in the message to see the actual returned type","Add a conversion (e.g. fmt.Sprintf) only if the value is genuinely a non-string ID","Verify client and runtime versions agree on the request shape"],"exampleFix":"// before\nid, err := req.RequestId()\n// after\nid, err := req.RequestId()\nif err != nil && strings.Contains(err.Error(), \"unexpected type for ID: float64\") {\n    log.Printf(\"runtime returned numeric ID; upgrade runtime or coerce\")\n}","handlingStrategy":"try-catch","validationCode":"// Cannot pre-validate; validate after call:\nid, err := req.RequestId()\nif err == nil && id == \"\" { /* runtime returned empty/non-string id */ }","typeGuard":"func isString(v any) bool { _, ok := v.(string); return ok }","tryCatchPattern":"id, err := req.RequestId()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type\") {\n        return fmt.Errorf(\"runtime returned non-string ID: %w\", err)\n    }\n    return err\n}","preventionTips":["Ensure runtime 'id' implementations return plain strings","Add contract tests asserting RequestId() returns a string","Pin client/runtime versions together"],"tags":["go","type-mismatch","request-id"],"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"}