{"record":{"id":"98896f77d3ddb3d7","repo":"microsoft/aspire","slug":"tracked-browser-protocol-response-id-was-not-an-integer","errorCode":null,"errorMessage":"Tracked browser protocol response id was not an integer.","messagePattern":"Tracked browser protocol response id was not an integer\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Browsers/BrowserLogsCdpProtocol.cs","lineNumber":97,"sourceCode":"            }\n\n            if (reader.TokenType != JsonTokenType.PropertyName)\n            {\n                throw new InvalidOperationException(\"Tracked browser protocol frame was malformed.\");\n            }\n\n            var propertyName = reader.GetString();\n            if (!reader.Read())\n            {\n                throw new InvalidOperationException(\"Tracked browser protocol frame ended unexpectedly.\");\n            }\n\n            switch (propertyName)\n            {\n                case \"id\":\n                    if (!reader.TryGetInt64(out var parsedId))\n                    {\n                        throw new InvalidOperationException(\"Tracked browser protocol response id was not an integer.\");\n                    }\n\n                    id = parsedId;\n                    break;\n                case \"method\":\n                    method = reader.TokenType == JsonTokenType.String\n                        ? reader.GetString()\n                        : throw new InvalidOperationException(\"Tracked browser protocol event method was not a string.\");\n                    break;\n                case \"sessionId\":\n                    sessionId = reader.TokenType == JsonTokenType.String\n                        ? reader.GetString()\n                        : null;\n                    break;\n                default:\n                    reader.Skip();\n                    break;\n            }","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Browsers/BrowserLogsCdpProtocol.cs#L79-L115","documentation":"In a CDP response frame, the \"id\" property must be an integer correlating the response with its command. If the parser sees an \"id\" property whose value is not an integer (string, null, object, etc.), it throws this InvalidOperationException. CDP replies always use numeric ids, so a non-numeric id means a non-conforming or corrupted frame.","triggerScenarios":"ParseMessageHeader reads property name \"id\" and Utf8JsonReader.TryGetInt64 fails - the value is e.g. \"id\": \"7\" (string), null, or an object instead of a JSON number.","commonSituations":"A wrapper/proxy rewrites CDP frames and serializes ids as strings, a custom automation tool sends non-standard frames, or a corrupted byte stream changes the value's type.","solutions":["Inspect the frame with DescribeFrame to see the id value's actual type","Ensure the browser is a standard Chromium build not wrapped by a proxy rewriting JSON","Check any middleware that forwards CDP frames preserves numeric id types","Skip or log non-conforming frames via try-catch instead of crashing"],"exampleFix":"// before\nvar header = BrowserLogsCdpProtocol.ParseMessageHeader(frame); // throws on \"id\":\"12\"\n// after\ntry\n{\n    var header = BrowserLogsCdpProtocol.ParseMessageHeader(frame);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"id was not an integer\"))\n{\n    logger.LogWarning(\"Non-standard CDP frame skipped: {Frame}\", BrowserLogsCdpProtocol.DescribeFrame(frame));\n}","handlingStrategy":"validation","validationCode":"// sanity check: CDP ids are integers; reject obviously wrong payloads early\n// no public pre-parse hook exists; validate at the source (proxy/browser config)","typeGuard":null,"tryCatchPattern":"try\n{\n    var header = BrowserLogsCdpProtocol.ParseMessageHeader(frame);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"id was not an integer\"))\n{\n    logger.LogWarning(\"CDP frame with non-integer id skipped\");\n}","preventionTips":["Avoid proxies that rewrite CDP JSON","Use standard Chromium channels","Test against real browser output, not hand-written fixtures with string ids"],"tags":["cdp","browser","type-mismatch","json"],"backgroundTag":"type-mismatch","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}