{"record":{"id":"6bd479f866abd9d0","repo":"dotnet/aspnetcore","slug":"invalid-payload-for-ack-message","errorCode":null,"errorMessage":"Invalid payload for Ack message.","messagePattern":"Invalid payload for Ack message\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts","lineNumber":267,"sourceCode":"                result = properties[4];\n                break;\n        }\n\n        const completionMessage: CompletionMessage = {\n            error,\n            headers,\n            invocationId: properties[2],\n            result,\n            type: MessageType.Completion,\n        };\n\n        return completionMessage;\n    }\n\n    private _createAckMessage(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 Ack message.\");\n        }\n\n        return {\n            sequenceId: properties[1],\n            type: MessageType.Ack,\n        } as HubMessage;\n    }\n\n    private _createSequenceMessage(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 Sequence message.\");\n        }\n\n        return {\n            sequenceId: properties[1],\n            type: MessageType.Sequence,\n        } as HubMessage;","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts#L249-L285","documentation":"Thrown by _createAckMessage when the decoded properties array has fewer than 1 element. An Ack message is part of SignalR's reliable-stream protocol and is encoded with MessageType.Ack as the first element plus a sequenceId; properties.length < 1 means even the type slot is absent. Note the subsequent read of properties[1] means a length-1 array will silently yield sequenceId=undefined — a separate quirk to be aware of.","triggerScenarios":"A frame typed as Ack routed to _createAckMessage with an empty array; only reachable if the upstream length-0 guard in _parseMessage is bypassed. Practically an internal invariant guard.","commonSituations":"Direct unit tests of _createAckMessage; a fork that modified _parseMessage; hypothetical corruption that also defeats the upstream check.","solutions":["Do not invoke _createAckMessage directly with empty input; rely on _parseMessage to gate.","If observed in production, investigate why the upstream length guard did not fire.","Confirm reliable-stream protocol is enabled consistently on both peers."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Internal invariant — protect via upstream guard\nfunction isValidAckProperties(p: unknown[]): boolean {\n  return p.length >= 2; // also recommend requiring the sequenceId slot\n}","typeGuard":"function isAckPayload(p: unknown[]): p is [number, number] {\n  return p.length >= 2 && typeof p[1] === 'number';\n}","tryCatchPattern":"// Internal — surfaced via _parseMessage's parsing flow; treat any such failure as connection-poisoning and reconnect.","preventionTips":["Do not call _createAckMessage directly with insufficient data.","Verify reliable-stream (Sequence/Ack) protocol is enabled consistently on both peers.","Treat Ack-frame corruption as a reconnect trigger."],"tags":["signalr","messagepack","ack","reliable-stream","invariant"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}