{"record":{"id":"93492921ab3fe9b6","repo":"dotnet/aspnetcore","slug":"invalid-invocation-result-kind","errorCode":null,"errorMessage":"Invalid invocation result kind.","messagePattern":"Invalid invocation result kind\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/java/signalr/messagepack/src/main/java/com/microsoft/signalr/messagepack/MessagePackHubProtocol.java","lineNumber":260,"sourceCode":"        Map<String, String> headers = readHeaders(unpacker);\n        String invocationId = unpacker.unpackString();\n        int resultKind = unpacker.unpackInt();\n\n        String error = null;\n        Object result = null;\n\n        switch (resultKind) {\n            case ERROR_RESULT:\n                error = unpacker.unpackString();\n                break;\n            case VOID_RESULT:\n                break;\n            case NON_VOID_RESULT:\n                Type itemType = binder.getReturnType(invocationId);\n                result = readValue(unpacker, itemType, payload, true);\n                break;\n            default:\n                throw new RuntimeException(\"Invalid invocation result kind.\");\n        }\n\n        return new CompletionMessage(headers, invocationId, result, error);\n    }\n\n    private HubMessage createStreamInvocationMessage(MessageUnpacker unpacker, InvocationBinder binder, int itemCount, ByteBuffer payload) throws IOException {\n        Map<String, String> headers = readHeaders(unpacker);\n        String invocationId = unpacker.unpackString();\n        String target = unpacker.unpackString();\n\n        Object[] arguments = null;\n        try {\n            List<Type> types = binder.getParameterTypes(target);\n            arguments = bindArguments(unpacker, types, payload);\n        } catch (Exception ex) {\n            return new InvocationBindingFailureMessage(invocationId, target, ex);\n        }\n","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/java/signalr/messagepack/src/main/java/com/microsoft/signalr/messagepack/MessagePackHubProtocol.java#L242-L278","documentation":"createCompletionMessage reads the integer result-kind field of an incoming CompletionMessage and switches on it; the protocol defines only ERROR_RESULT (1), VOID_RESULT (2), and NON_VOID_RESULT (3). Any other value means the message is malformed or produced by an incompatible peer, so the client refuses to interpret it.","triggerScenarios":"The server sends a CompletionMessage whose resultKind is not 1, 2, or 3 (see MessagePackHubProtocol.java:45-47, 249-261). This is a wire/protocol violation, typically from a version mismatch between client and server MessagePack protocol implementations.","commonSituations":"Upgrading one side of the connection to a newer SignalR protocol that changed the result-kind encoding, corrupted bytes deserializing to an unexpected int, or a non-Microsoft server emitting non-standard completion frames.","solutions":["Align the SignalR client and server to the same protocol version.","If you control the sender, ensure resultKind is strictly 1, 2, or 3.","Treat the occurrence as a connection-fatal protocol violation: tear down and reconnect to a compatible endpoint."],"exampleFix":"// before - server emits an out-of-range result kind\n// after - server uses the documented constants\npacker.packInt(/*ERROR_RESULT*/1); // or 2 VOID_RESULT, 3 NON_VOID_RESULT","handlingStrategy":"validation","validationCode":"// If you control the sender, assert resultKind is one of the defined constants before sending\nint[] VALID = {/*ERROR_RESULT*/1, /*VOID_RESULT*/2, /*NON_VOID_RESULT*/3};\nif (!IntStream.of(VALID).anyMatch(k -> k == resultKind)) {\n    throw new IllegalArgumentException(\"Bad result kind: \" + resultKind);\n}","typeGuard":"static boolean isValidResultKind(int k) {\n    return k == 1 || k == 2 || k == 3;\n}","tryCatchPattern":"try {\n    protocol.parseMessages(buffer, binder);\n} catch (RuntimeException ex) {\n    if (\"Invalid invocation result kind.\".equals(ex.getMessage())) {\n        // protocol violation - reconnect to a compatible server\n        connection.stop();\n    }\n    throw ex;\n}","preventionTips":["Run client and server on the same SignalR MessagePack protocol version.","Reject non-Microsoft peers that emit non-standard completion frames.","Treat this as connection-fatal and reconnect."],"tags":["java","signalr","messagepack","protocol","deserialization"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}