{"record":{"id":"d4f574dad4b29a47","repo":"microsoft/FASTER","slug":"unexpected-status-of-subscribekv","errorCode":null,"errorMessage":"Unexpected status of SubscribeKV","messagePattern":"Unexpected status of SubscribeKV","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"cs/remote/src/FASTER.client/ClientSession.cs","lineNumber":525,"sourceCode":"                            }\n                        case MessageType.Subscribe:\n                            {\n                                var status = ReadStatus(ref src);\n                                var p = hrw.ReadPendingSeqNo(ref src);\n                                if (status.IsPending)\n                                {\n                                    var result = pubsubQueue.Dequeue();\n                                    pubsubPendingContext.Add(p, result);\n                                }\n                                else if (status.Found)\n                                {\n                                    pubsubPendingContext.TryGetValue(p, out var result);\n                                    result.Item2 = serializer.ReadValue(ref src);\n                                    functions.SubscribeCallback(ref result.Item1, ref result.Item2, result.Item3);\n                                }\n                                else\n                                {\n                                    throw new Exception(\"Unexpected status of SubscribeKV\");\n                                }\n                                break;\n                            }\n                        case MessageType.PSubscribe:\n                            {\n                                var status = ReadStatus(ref src);\n                                var p = hrw.ReadPendingSeqNo(ref src);\n                                if (status.IsPending)\n                                {\n                                    var result = pubsubQueue.Dequeue();\n                                    pubsubPendingContext.Add(p, result);\n                                }\n                                else if (status.Found)\n                                {\n                                    pubsubPendingContext.TryGetValue(p, out var result);\n                                    result.Item1 = serializer.ReadKey(ref src);\n                                    result.Item2 = serializer.ReadValue(ref src);\n                                    functions.SubscribeCallback(ref result.Item1, ref result.Item2, result.Item3);","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/remote/src/FASTER.client/ClientSession.cs#L507-L543","documentation":"While processing replies to a SubscribeKV operation, the client read a status code from the server that is neither Success nor the expected pending/complete markers. The library only knows how to deserialize the subscribe result for known statuses, so any other status is fatal and thrown. It indicates a protocol mismatch or unexpected server-side state for the subscribed key/value.","triggerScenarios":"Server responds to a MessageType.SubscribeKV with a status other than SUCCESS (e.g., key not found at subscribe time, or an error status) while the reply handler for SubscribeKV only accepts the success path.","commonSituations":"Subscribing to a key that was deleted concurrently on the server; client and server versions disagree on SubscribeKV status codes; using SubscribeKV against a server build without full pub/sub KV support.","solutions":["Upgrade client and server FASTER packages to matching versions so status codes align.","Check that the subscribed key exists and is not concurrently deleted on the server before subscribing.","Wrap the subscribe call in error handling and retry with a fresh session if the server returned a transient failure status.","If reproducing consistently, capture the raw status and file an issue / inspect server code for the unsupported status path."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-check key existence on the main session before subscribing\nvar (status, _) = session.Read(key);\nif (status != Status.OK) { /* skip or create key first */ }","typeGuard":null,"tryCatchPattern":"try { SubscribeKV(key, value, callback); }\ncatch (Exception ex) when (ex.Message.Contains(\"Unexpected status of SubscribeKV\"))\n{\n    // recreate session and retry subscribe with backoff\n    RecreateSession(); RetrySubscribeWithBackoff(key);\n}","preventionTips":["Keep FASTER client and server versions identical.","Ensure subscribed keys exist and aren't concurrently deleted.","Retry subscribe operations on transient failures.","Enable server-side pub/sub before using SubscribeKV."],"tags":["csharp","pubsub","protocol","faster"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}