fix: check cursor fields instead of re-encoding

628b5f2 accepted a cursor only if re-encoding the parsed key gave the
same string. That closed the format both ways: any encoding change, even
a compatible one (an optional field, key order, to_rfc3339 shared with
API responses), would turn cursors issued by a replica of the other
version into 400 during make rolling_update, which the tests cannot see.

decode_cursor now checks the fields one by one: v must be exactly the
integer 1, t and i must be strings, i must be in the server's notation
(lowercase 8-4-4-4-12). Unknown fields are ignored, so a tampered cursor
is still a 400 while the format stays open for compatible changes. The
rule records how to change the format: a new CURSOR_VERSION, with both
versions accepted while replicas are replaced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-16 13:11:57 +03:00
co-authored by Claude Opus 5.5
parent 628b5f2278
commit 8fe467ace0
8 changed files with 170 additions and 76 deletions
@@ -26,11 +26,13 @@
## What Changes
- **Курсор принимается только в записи, которую выдал сервер.**
- **Подменённый курсор — 400.**
- Значения не того типа больше не роняют разбор.
- Подмена любого поля — `"i"`, `"t"`, `"v"`, лишнее поле, другая
запись UUID или времени — даёт 400 `invalid_request`, а не 500 и не
200.
- Ключ элемента не строка или не в записи сервера, версия не ровно
целое 1 — 400 `invalid_request`, а не 500 и не 200.
- Незнакомые поля игнорируются: формат остаётся открытым для
совместимых правок, и курсоры не ломаются при поочерёдной замене
реплик (design, «Пересмотр в apply»).
- **UUID на входе — только запись 8-4-4-4-12.** Это `chat_id` в пути трёх
ручек (`GET /chats/{chat_id}`, `GET` и `POST
/chats/{chat_id}/messages`) и элементы `member_ids` в `POST /chats`.