{"record":{"id":"64f958e495df8034","repo":"dotnet/orleans","slug":"inform-grain-id-in-format-id-additionalkey-64f958","errorCode":null,"errorMessage":"Inform grain id in format {id},{additionalKey}","messagePattern":"Inform grain id in format (.+?),(.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Dashboard/Orleans.Dashboard/Implementation/Helpers/GrainStateHelper.cs","lineNumber":30,"sourceCode":"    {\n        object? grainId = null;\n        string keyExtension = \"\";\n        var splitedGrainId = id.Split(\",\");\n\n        try\n        {\n            if (implementationType.IsAssignableTo(typeof(IGrainWithGuidCompoundKey)))\n            {\n                if (splitedGrainId.Length != 2)\n                    throw new InvalidOperationException(\"Inform grain id in format `{ id},{additionalKey}`\");\n\n                grainId = Guid.Parse(splitedGrainId.First());\n                keyExtension = splitedGrainId.Last();\n            }\n            else if (implementationType.IsAssignableTo(typeof(IGrainWithIntegerCompoundKey)))\n            {\n                if (splitedGrainId.Length != 2)\n                    throw new InvalidOperationException(\"Inform grain id in format {id},{additionalKey}\");\n\n                grainId = Convert.ToInt64(splitedGrainId.First());\n                keyExtension = splitedGrainId.Last();\n            }\n            else if (implementationType.IsAssignableTo(typeof(IGrainWithIntegerKey)))\n            {\n                grainId = Convert.ToInt64(id);\n            }\n            else if (implementationType.IsAssignableTo(typeof(IGrainWithGuidKey)))\n            {\n                grainId = Guid.Parse(id);\n            }\n            else if (implementationType.IsAssignableTo(typeof(IGrainWithStringKey)))\n            {\n                grainId = id;\n            }\n        }\n        catch (Exception ex)","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Dashboard/Orleans.Dashboard/Implementation/Helpers/GrainStateHelper.cs#L12-L48","documentation":"InvalidOperationException from GrainStateHelper.GetGrainId when the implementation type implements IGrainWithIntegerCompoundKey but the id does not split into exactly two comma-separated parts. Requires exactly 'integer,additionalKey'. Note the message text differs slightly from error 355 (no stray backticks) but the contract is identical for integer compound keys.","triggerScenarios":"Dashboard requests grain state for a grain whose implementation type is IGrainWithIntegerCompoundKey, and the id string does not contain exactly one comma (splitedGrainId.Length != 2). Convert.ToInt64 on a non-numeric first part would also throw and be wrapped by error 357.","commonSituations":"Malformed id from the dashboard UI, a grain registered with an integer compound key but invoked with only the long portion, or frontend code that omits the additional key.","solutions":["Pass ids for integer-compound grains as 'long,additionalKey' with exactly one comma.","Validate format and that the first part is a 64-bit integer before calling.","Confirm the grain interface marker type matches the key shape you expect."],"exampleFix":"// before\nvar (gid, ext) = GrainStateHelper.GetGrainId(rawId, typeof(MyIntCompoundGrain));\n\n// after\nvar parts = rawId.Split(',');\nif (parts.Length != 2 || !long.TryParse(parts[0], out _))\n    return BadRequest(\"id must be 'long,additionalKey'\");\nvar (gid, ext) = GrainStateHelper.GetGrainId(rawId, typeof(MyIntCompoundGrain));","handlingStrategy":"validation","validationCode":"var parts = id.Split(',');\nif (parts.Length != 2 || !long.TryParse(parts[0], out _))\n    return BadRequest(\"id must be 'long,additionalKey'\");\nvar (gid, ext) = GrainStateHelper.GetGrainId(id, type);","typeGuard":"static bool IsValidIntCompoundId(string id) =>\n    id.Split(',') is { Length: 2 } p && long.TryParse(p[0], out _);","tryCatchPattern":"try { var (gid, ext) = GrainStateHelper.GetGrainId(id, type); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"grain id in format\"))\n{ return BadRequest(\"compound integer id malformed\"); }","preventionTips":["Validate the 'long,key' format before requesting grain state","Ensure frontend sends both segments","Match interface markers to the key type"],"tags":["dashboard","grain-id","argument-validation","parsing"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}