Skip to content

UTS: answer batch publish and revokeTokens mocks with the BatchResult envelope - #589

Open
owenpearson wants to merge 2 commits into
fix/uts-publish-body-assertionsfrom
fix/uts-batch-response-envelope
Open

owenpearson wants to merge 2 commits into
fix/uts-publish-body-assertionsfrom
fix/uts-batch-response-envelope

Conversation

@owenpearson

Copy link
Copy Markdown
Member

Closes #559

Stacked on #537 (fix/uts-publish-body-assertions) and must merge after it. #537 pins useBinaryProtocol: false in the body-reading sections of these same two files, RSC22_Headers1 included, so its Content-Type: application/json line is already consistent and is not touched here.

What was wrong

batch_publish.md mocked the response the server sends below protocol version 3: a bare per-channel result object, or a flat array of per-channel results, and RSC22_Headers1 pinned X-Ably-Version: 2, the version that gets that format. An SDK that sends the CSV2b protocol version (RSC7e) and returns BatchResults as RSC22b says cannot pass those mocks, and one that passes them is parsing a response it will never receive. revoke_tokens.md had the same fault in the mocks that answer an all-success batch.

The shape

Measured against the sandbox in #559, and used by ably-python's batch publish (ably/ably-pubsub-python#727), which sends version 5: POST /messages returns HTTP 201 and an array holding one BatchResult envelope per BatchPublishSpec, each {successCount, failureCount, results} (BAR2). A single spec sent as a bare object gets an array of one, which is the array RSC22b says the REST API still returns. All-success, mixed and all-failure batches all answer 201 in this format. serials (BPR2c) was added to the spec at protocol version 5, so the fixtures here are the version 5 response.

revokeTokens returns one BatchResult (RSA17c), not one per spec, so its mocks become a single envelope object, as the file's existing Server Response Format section and its RSA17c_2/RSA17c_3/TRF2_1 mocks already show.

Changes

uts/rest/unit/batch_publish.md

  • New Server Response Format section, modelled on batch_presence.md's, describing the envelope array, the single-spec case, status codes, serials, and the legacy format (version 2 or below: one flat array across all specs, no serials, 400/40020 with batchResponse when any channel fails).
  • Every batch result fixture wrapped in the envelope with HTTP 201: RSC22c3, RSC22c4 (two envelopes, one per spec), RSC22c5, BPR2a, BPR2b, BPR2c, BPR2c1, BPF2a, BPF2b, BatchResult1 (one envelope, successCount: 1, failureCount: 1) and RSC22_Batch2. RSC22c5 and RSC22_Batch2 previously said only "respond with results for each channel"; they now give the fixture.
  • BPR/BPF sections call batchPublish and read the fields through result.results[0]; BatchResult1 reads result.results[0]/[1] rather than result[0]/[1]. RSC22c4 names its two specs so "each result corresponds to the respective spec" can be checked.
  • RSC22_Headers1: X-Ably-Version is the CSV2b version, matching [0-9]+ and at least 5, instead of 2.

uts/rest/unit/auth/revoke_tokens.md

  • The eleven mocks that answered 200 with a bare array of results (RSA17g_1, RSA17b_1, RSA17b_2, RSA17c_1, TRS2_1, RSA17e_1, RSA17e_2, RSA17f_1, RSA17f_2, RSA17f_3, RSA17_Auth_1) now answer 201 with a BatchResult envelope. The issue named two of them (RSA17c_1 and TRS2_1, which assert envelope fields); the other nine only read the request, but carried the same legacy body.
  • The two RSA17d mocks (200, []) are never reached, since token auth is rejected before any request; they get an empty envelope so no legacy body is left in the file.
  • RSA17c_2 (mixed) moves from 200 to 201, which is what the file's header and the server give for a mixed batch. The all-failure mocks (RSA17c_3, TRF2_1) keep 200: the server's status for an all-failure revocation wasn't measured.

No Test IDs changed. npm run lint passes.

🤖 Generated with Claude Code

owenpearson and others added 2 commits November 27, 2026 13:50
batch_publish.md mocked the response the server sends below protocol
version 3: a bare per-channel result, or a flat array of them. At the
CSV2b version POST /messages returns HTTP 201 and an array holding one
BatchResult envelope per BatchPublishSpec, which is what RSC22b means by
"the response will still be an array".

Add a Server Response Format section, wrap every batch result fixture in
the envelope (RSC22c3, RSC22c4, RSC22c5, BPR2a, BPR2b, BPR2c, BPR2c1,
BPF2a, BPF2b, BatchResult1, RSC22_Batch2), read the BPR/BPF fields through
result.results[0], and check RSC22_Headers1's X-Ably-Version against a
pattern of at least 5 instead of pinning 2, the version that gets the
legacy format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eleven revokeTokens mocks stubbed HTTP 200 and a bare array of results,
the legacy format the file's own Server Response Format section says no
current SDK sees, while RSA17c_1 and TRS2_1 assert envelope fields. Wrap
them in a single BatchResult envelope with HTTP 201, as the header
describes, and do the same to the two unreachable RSA17d mocks.

RSA17c_2's mixed response is also moved from 200 to 201, which is what
the header and the server give for a mixed batch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
staging/pull/589 — 4398d41e Deployed Nov 27, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant