{"record":{"id":"c3febb8f7be4cd86","repo":"dotnet/aspnetcore","slug":"invalid-payload-for-ping-message","errorCode":null,"errorMessage":"Invalid payload for Ping message.","messagePattern":"Invalid payload for Ping message\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts","lineNumber":178,"sourceCode":"\n    private _createCloseMessage(properties: any[]): HubMessage {\n        // check minimum length to allow protocol to add items to the end of objects in future releases\n        if (properties.length < 2) {\n            throw new Error(\"Invalid payload for Close message.\");\n        }\n\n        return {\n            // Close messages have no headers.\n            allowReconnect: properties.length >= 3 ? properties[2] : undefined,\n            error: properties[1],\n            type: MessageType.Close,\n        } as HubMessage;\n    }\n\n    private _createPingMessage(properties: any[]): HubMessage {\n        // check minimum length to allow protocol to add items to the end of objects in future releases\n        if (properties.length < 1) {\n            throw new Error(\"Invalid payload for Ping message.\");\n        }\n\n        return {\n            // Ping messages have no headers.\n            type: MessageType.Ping,\n        } as HubMessage;\n    }\n\n    private _createInvocationMessage(headers: MessageHeaders, properties: any[]): InvocationMessage {\n        // check minimum length to allow protocol to add items to the end of objects in future releases\n        if (properties.length < 5) {\n            throw new Error(\"Invalid payload for Invocation message.\");\n        }\n\n        const invocationId = properties[2] as string;\n        if (invocationId) {\n            return {\n                arguments: properties[4],","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts#L160-L196","documentation":"Thrown by _createPingMessage when the decoded properties array has fewer than 1 element. A Ping message is encoded as [MessageType.Ping] — just the type byte. If properties.length < 1, the frame was completely empty, which is impossible for a valid Ping (the type byte alone makes length 1).","triggerScenarios":"Effectively unreachable in normal operation because _parseMessage already rejects length-0 inputs (error 110). Could surface only if _parseMessage's check is bypassed or if properties was mis-routed to _createPingMessage with an empty array.","commonSituations":"Direct unit testing of _createPingMessage with empty arrays; a fork that modified the upstream _parseMessage length guard; hypothetical protocol corruption that also slips past the upstream check.","solutions":["Do not call _createPingMessage directly with empty input; this is an internal invariant guard.","If hit, inspect upstream: the length-0 guard in _parseMessage should have fired first.","Report as a protocol bug if observed in the wild — indicates corrupted frame routing."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Internal invariant — protect by upstream guard in _parseMessage\nif (input.length === 0) throw new Error('Empty Ping payload');\n// _createPingMessage will then never receive an empty array.","typeGuard":"function isNonEmptyArray(a: unknown[]): boolean { return a.length >= 1; }","tryCatchPattern":"// not user-facing — surfaced only through _parseMessage which already rejects length 0","preventionTips":["Do not bypass the upstream _parseMessage length guard.","Do not call _createPingMessage directly in app code."],"tags":["signalr","messagepack","ping","validation","invariant"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}