{"record":{"id":"b34b4e26d6466794","repo":"dotnet/aspnetcore","slug":"invalid-payload-for-invocation-message","errorCode":null,"errorMessage":"Invalid payload for Invocation message.","messagePattern":"Invalid payload for Invocation message\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts","lineNumber":190,"sourceCode":"        } 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],\n                headers,\n                invocationId,\n                streamIds: [],\n                target: properties[3] as string,\n                type: MessageType.Invocation,\n            };\n        } else {\n            return {\n                arguments: properties[4],\n                headers,\n                streamIds: [],\n                target: properties[3],","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts#L172-L208","documentation":"Thrown by _createInvocationMessage when the decoded properties array has fewer than 5 elements. The Invocation message layout is [MessageType.Invocation, headers, invocationId, target, arguments, streamIds?]. Fewer than 5 means required fields (typically target or arguments) are missing.","triggerScenarios":"A server/peer sent an Invocation frame missing the target or arguments slot; corrupt bytes that decoded to an array of length 1-4 but were typed as Invocation; a non-conforming hub method invocation.","commonSituations":"Protocol version mismatch (older/newer server with a different Invocation layout); corrupted wire data; malicious peer; testing the parser with truncated arrays.","solutions":["Verify the server runs a compatible SignalR MessagePack protocol version.","Inspect the decoded properties array contents to identify the missing slot.","Treat as connection-poisoning: close and reconnect."],"exampleFix":"// before\n// server emits [1, {}, '42', 'Send']  — missing arguments → throws\n\n// after — server must include all required slots\n// emit [1, {}, '42', 'Send', [], []]  (arguments, streamIds)","handlingStrategy":"validation","validationCode":"function isValidInvocationProperties(p: unknown[]): boolean {\n  return p.length >= 5;\n}","typeGuard":"function isInvocationPayload(p: unknown[]): p is [number, unknown, string | null, string, unknown[], unknown[]?] {\n  return p.length >= 5;\n}","tryCatchPattern":"try { return protocol.parseMessages(buf, logger); }\ncatch (e) {\n  if (/Invalid payload for Invocation/.test((e as Error).message)) {\n    logger.log(LogLevel.Error, 'Malformed Invocation — reconnecting');\n    await connection.stop(); await connection.start();\n  } else throw e;\n}","preventionTips":["Verify the server's hub invocation encoder includes target and arguments slots.","Align client/server SignalR protocol versions.","Treat malformed invocations as poison and reconnect."],"tags":["signalr","messagepack","invocation","validation","wire-format"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}