Skip to content

Missed CAS error code #782

@alamaison

Description

@alamaison

Observed behavior

The client currently handles error code 10071 (JSStreamWrongLastSequenceErrF) and converts it to a KeyWrongLastSequenceError so that the client can retry the CAS collision. But the server also returns error code 10164 (JSStreamWrongLastSequenceConstantErr) which seems to represent the same condition, but the SDK doesn't handle it. That means the caller has to do something like this on every jetstream call:

            except (KeyWrongLastSequenceError, BadRequestError) as e:
                should_retry = isinstance(e, KeyWrongLastSequenceError) or (
                    isinstance(e, BadRequestError)
                    and getattr(e, "err_code", None) == 10164
                )
                if not should_retry:
                    # not a CAS 400 — raise it
                    raise

getattr is necessary because the exceptions don't always have the error code set.

This should be handled consistently in the SDK

Expected behavior

A jetstream call, e.g. update, raises a KeyWrongLastSequenceError in all cases where a CAS retry is appropriate

Server and client version

Client: 2.11.0
Server: 2.11.5

Host environment

No response

Steps to reproduce

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectSuspected defect such as a bug or regression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions