{"record":{"id":"a432ec2fb22f57db","repo":"dotnet/aspnetcore","slug":"invalid-payload-for-completion-message-a432ec","errorCode":null,"errorMessage":"Invalid payload for Completion message.","messagePattern":"Invalid payload for Completion message\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr/src/JsonHubProtocol.ts","lineNumber":111,"sourceCode":"    private _isInvocationMessage(message: InvocationMessage): void {\n        this._assertNotEmptyString(message.target, \"Invalid payload for Invocation message.\");\n\n        if (message.invocationId !== undefined) {\n            this._assertNotEmptyString(message.invocationId, \"Invalid payload for Invocation message.\");\n        }\n    }\n\n    private _isStreamItemMessage(message: StreamItemMessage): void {\n        this._assertNotEmptyString(message.invocationId, \"Invalid payload for StreamItem message.\");\n\n        if (message.item === undefined) {\n            throw new Error(\"Invalid payload for StreamItem message.\");\n        }\n    }\n\n    private _isCompletionMessage(message: CompletionMessage): void {\n        if (message.result && message.error) {\n            throw new Error(\"Invalid payload for Completion message.\");\n        }\n\n        if (!message.result && message.error) {\n            this._assertNotEmptyString(message.error, \"Invalid payload for Completion message.\");\n        }\n\n        this._assertNotEmptyString(message.invocationId, \"Invalid payload for Completion message.\");\n    }\n\n    private _isAckMessage(message: AckMessage): void {\n        if (typeof message.sequenceId !== 'number') {\n            throw new Error(\"Invalid SequenceId for Ack message.\");\n        }\n    }\n\n    private _isSequenceMessage(message: SequenceMessage): void {\n        if (typeof message.sequenceId !== 'number') {\n            throw new Error(\"Invalid SequenceId for Sequence message.\");","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/ts/signalr/src/JsonHubProtocol.ts#L93-L129","documentation":"Thrown by JsonHubProtocol._isCompletionMessage for three distinct malformed-Completion conditions: (1) both `result` and `error` are truthy, (2) `error` is truthy but `result` is falsy AND `error` is not a non-empty string, or (3) `invocationId` is not a non-empty string. A well-formed Completion carries exactly one of error/result and always a non-empty invocationId.","triggerScenarios":"Server returns a Completion message where: result and error are both set; error is set to an empty string or non-string; or invocationId is missing/empty. Also triggered by a malformed/injected frame.","commonSituations":"Server hub method throws but the error serializer emits an empty message, a proxy rewrites the payload dropping invocationId, or a hand-written server implementation that populates result and error together.","solutions":["Ensure the server sets either `result` or `error` (never both) on Completion.","Make sure error is a non-empty string when present.","Always include the invocationId matching the originating invocation/stream."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function validCompletion(m: any): boolean {\n  const hasResult = !!m.result;\n  const hasErr = !!m.error;\n  if (hasResult && hasErr) return false;\n  if (hasErr && !hasResult && (typeof m.error !== \"string\" || m.error === \"\")) return false;\n  return typeof m.invocationId === \"string\" && m.invocationId !== \"\";\n}","typeGuard":"function isWellFormedCompletion(m: any): boolean {\n  if (!m) return false;\n  if (m.result && m.error) return false;\n  if (m.error && typeof m.error !== \"string\") return false;\n  return typeof m.invocationId === \"string\" && m.invocationId.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Set exactly one of result or error on Completion.","Provide a non-empty error string.","Always include the originating invocationId."],"tags":["protocol","json","parsing","message-type"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}