{"record":{"id":"e7a004bd939ef754","repo":"dotnet/aspnetcore","slug":"invalid-payload","errorCode":null,"errorMessage":"Invalid payload.","messagePattern":"Invalid payload\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts","lineNumber":129,"sourceCode":"                return this._writeCompletion(message as CompletionMessage);\n            case MessageType.Ping:\n                return BinaryMessageFormat.write(SERIALIZED_PING_MESSAGE);\n            case MessageType.CancelInvocation:\n                return this._writeCancelInvocation(message as CancelInvocationMessage);\n            case MessageType.Close:\n                return this._writeClose();\n            case MessageType.Ack:\n                return this._writeAck(message as AckMessage);\n            case MessageType.Sequence:\n                return this._writeSequence(message as SequenceMessage);\n            default:\n                throw new Error(\"Invalid message type.\");\n        }\n    }\n\n    private _parseMessage(input: Uint8Array, logger: ILogger): HubMessage | null {\n        if (input.length === 0) {\n            throw new Error(\"Invalid payload.\");\n        }\n\n        const properties = this._decoder.decode(input) as any;\n        if (properties.length === 0 || !(properties instanceof Array)) {\n            throw new Error(\"Invalid payload.\");\n        }\n\n        const messageType = properties[0] as MessageType;\n\n        switch (messageType) {\n            case MessageType.Invocation:\n                return this._createInvocationMessage(this._readHeaders(properties), properties);\n            case MessageType.StreamItem:\n                return this._createStreamItemMessage(this._readHeaders(properties), properties);\n            case MessageType.Completion:\n                return this._createCompletionMessage(this._readHeaders(properties), properties);\n            case MessageType.Ping:\n                return this._createPingMessage(properties);","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts#L111-L147","documentation":"Thrown by _parseMessage when the per-message Uint8Array slice passed in has length 0. Each SignalR MessagePack frame is expected to contain at least a message-type byte; an empty slice means the framing layer handed the parser a zero-length payload.","triggerScenarios":"A length-prefix declared a payload of size 0 followed by no body bytes; BinaryMessageFormat.parse returned an empty subarray (rare but possible with prefix size 0); a malformed peer sending zero-length frames.","commonSituations":"Corrupt or hand-crafted wire data; an upstream framing bug producing zero-length frames; testing with arbitrary byte sequences; a peer exploiting the protocol to send a no-op frame.","solutions":["Treat the connection as broken: this indicates protocol corruption; close and reconnect the HubConnection.","Verify the peer is a compliant SignalR MessagePack endpoint.","Filter zero-length subarrays out of test fixtures when fuzzing the parser."],"exampleFix":"// before\n// peer sent a frame with declared size 0 → _parseMessage gets []\n\n// after — guard at the framing boundary\nfor (const m of messages) {\n  if (m.length === 0) { logger.log(LogLevel.Warning, 'Skipping zero-length frame'); continue; }\n  protocol._parseMessage(m, logger);\n}","handlingStrategy":"validation","validationCode":"function assertNonEmptyMessage(bytes: Uint8Array) {\n  if (bytes.length === 0) throw new Error('Refusing to parse empty MessagePack frame');\n}","typeGuard":"function isNonEmptyFrame(bytes: Uint8Array): boolean { return bytes.length > 0; }","tryCatchPattern":"for (const frame of frames) {\n  if (frame.length === 0) { logger.log(LogLevel.Warning, 'Skipping empty frame'); continue; }\n  try { protocol._parseMessage(frame, logger); } catch (e) { /* connection-level */ }\n}","preventionTips":["Filter zero-length frames at the framing boundary.","Treat this error as protocol corruption when seen via the public API.","Reconnect rather than retry parsing."],"tags":["signalr","messagepack","validation","empty-payload","corruption"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}