microsoft/FASTER · error · Exception

Unexpected status of SubscribeKV

Error message

Unexpected status of SubscribeKV

What it means

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.

Solutions

  1. Upgrade client and server FASTER packages to matching versions so status codes align.
  2. Check that the subscribed key exists and is not concurrently deleted on the server before subscribing.
  3. Wrap the subscribe call in error handling and retry with a fresh session if the server returned a transient failure status.
  4. If reproducing consistently, capture the raw status and file an issue / inspect server code for the unsupported status path.
Defensive patterns

Strategy: retry

Validate before calling

// pre-check key existence on the main session before subscribing
var (status, _) = session.Read(key);
if (status != Status.OK) { /* skip or create key first */ }

Try / catch

try { SubscribeKV(key, value, callback); }
catch (Exception ex) when (ex.Message.Contains("Unexpected status of SubscribeKV"))
{
    // recreate session and retry subscribe with backoff
    RecreateSession(); RetrySubscribeWithBackoff(key);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of microsoft/FASTER@321d872eab (2026-09-15). Data as JSON: /api/errors/d4f574dad4b29a47. Report an issue: GitHub.

Appendix: source

Thrown at cs/remote/src/FASTER.client/ClientSession.cs:525

                            }
                        case MessageType.Subscribe:
                            {
                                var status = ReadStatus(ref src);
                                var p = hrw.ReadPendingSeqNo(ref src);
                                if (status.IsPending)
                                {
                                    var result = pubsubQueue.Dequeue();
                                    pubsubPendingContext.Add(p, result);
                                }
                                else if (status.Found)
                                {
                                    pubsubPendingContext.TryGetValue(p, out var result);
                                    result.Item2 = serializer.ReadValue(ref src);
                                    functions.SubscribeCallback(ref result.Item1, ref result.Item2, result.Item3);
                                }
                                else
                                {
                                    throw new Exception("Unexpected status of SubscribeKV");
                                }
                                break;
                            }
                        case MessageType.PSubscribe:
                            {
                                var status = ReadStatus(ref src);
                                var p = hrw.ReadPendingSeqNo(ref src);
                                if (status.IsPending)
                                {
                                    var result = pubsubQueue.Dequeue();
                                    pubsubPendingContext.Add(p, result);
                                }
                                else if (status.Found)
                                {
                                    pubsubPendingContext.TryGetValue(p, out var result);
                                    result.Item1 = serializer.ReadKey(ref src);
                                    result.Item2 = serializer.ReadValue(ref src);
                                    functions.SubscribeCallback(ref result.Item1, ref result.Item2, result.Item3);

View on GitHub (pinned to 321d872eab)