Skip to content

UTS: fix publish-body assertions and pin protocol per test - #537

Open
owenpearson wants to merge 5 commits into
mainfrom
fix/uts-publish-body-assertions
Open

owenpearson wants to merge 5 commits into
mainfrom
fix/uts-publish-body-assertions

Conversation

@owenpearson

@owenpearson owenpearson commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Fixes the publish-body and protocol-pinning defects in #527, including the realtime RTL6i1 case from the follow-up comment. The delta-decoding item from that comment is a different kind of fault and is left for a separate change (see "Not in this PR").

Defects fixed (contradictions with RSL4c3/RSL1k)

  • channel/publish.md RSL1a publish-message-array-1: object payload was asserted unstringified; now asserts a stringified data string, decodes it, and asserts encoding == "json" (matching the message_encoding.md idiom).
  • channel/publish.md RSL1e null-name-and-data-0: dropped the whole-body-equality against a literal that omits the idempotency id (RSL1k1); now asserts field-wise plus the existing NOT IN omission checks.
  • channel/idempotency.md RSL1k mixed-ids-in-batch-1: removed the assertion that a library id is generated for the id-less message in a mixed batch (RSL1k1's precondition excludes this; RSL1k3 forbids it); now asserts "id" NOT IN body[1]. Prose and the inline comment on the id-less message rewritten to state RSL1k3.
  • realtime/unit/channels/channel_publish.md RTL6i1 publish-message-object-1 (from the Three REST publish-body assertions contradict features.md (RSL4c3/RSL4d3, RSL1k1, RSL1k3), and eight unit specs read the request body without pinning the protocol #527 follow-up comment): same fault as RSL1a. RTL6a encodes a realtime publish as RestChannel#publish does, so the test now asserts data IS String, parse_json(data) == {"key": "value"} and encoding == "json", with the protocol pinned to JSON.

Protocol pinned per test

useBinaryProtocol defaults to true (TO3f), so parse_json(request.body) only holds under JSON. Added useBinaryProtocol: false to the client in every unit section that reads the request body or asserts on its encoding:

A grep of every parse_json/JSON_PARSE/json_decode of a request body under uts/rest/unit, uts/realtime/unit and uts/objects/unit now finds none outside a pinned section. The batch response shapes and X-Ably-Version: 2 in batch_publish.md/revoke_tokens.md are #559 and are not touched here.

Doc convention

Added a note to docs/writing-test-specs.md: unit specs default to JSON when unpinned, and any spec whose assertions depend on the encoding must pin useBinaryProtocol (citing message_encoding.md as the pattern).

Not in this PR

From the #527 follow-up comment, realtime/unit/channels/channel_delta_decoding.md: four tests (RTL21 ascending index order, RTL19b stores base payload, RTL19c delta result becomes base, PC3 vcdiff plugin decodes) send a delta with bare encoding: "vcdiff" and assert a string result. That is a decode-side pipeline fault rather than a publish-body or protocol-pinning one, so it stays open on #527.

Files changed

  • uts/docs/writing-test-specs.md
  • uts/rest/unit/channel/publish.md
  • uts/rest/unit/channel/idempotency.md
  • uts/rest/unit/channel/annotations.md
  • uts/rest/unit/channel/update_delete_message.md
  • uts/rest/unit/batch_publish.md
  • uts/rest/unit/auth/revoke_tokens.md
  • uts/rest/unit/push/push_admin_publish.md
  • uts/rest/unit/push/push_channels.md
  • uts/rest/unit/push/push_channel_subscriptions.md
  • uts/rest/unit/push/push_device_registrations.md
  • uts/realtime/unit/channels/channel_publish.md

Merge order

PR 3 of 7. Merge after the mock-HTTP PR. Shares channel/idempotency.md with the spec-point-references PR and encoding/message_encoding.md with the broken-fixtures PR, so coordinate/rebase.

Part of #527

🤖 Generated with Claude Code

Corrects three publish request-body assertions that contradicted RSL4c3/RSL1k, and
makes rest/unit tests pin the protocol (JSON vs msgpack) they assume so that
parse_json(request.body) assertions are only made where they hold.

Closes #527

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
owenpearson and others added 4 commits November 27, 2026 13:16
Seven sections (RSA17b_1, RSA17b_2, RSA17e_1, RSA17e_2, RSA17f_1,
RSA17f_2, RSA17f_3) read the request body with JSON_PARSE on a plain-key
client, which TO3f makes msgpack. Set useBinaryProtocol: false on each,
as the rest of #527's fixes do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RSC22c6 was pinned already. The other sections that inspect the captured
request body (RSC22c1, RSC22c2, the three RSC22d sections, BSP2a, BSP2b,
RSC22_Batch1) now pin useBinaryProtocol: false too. RSC22_Headers1 is
pinned as well because it asserts Content-Type: application/json, which
only holds under JSON. Its X-Ably-Version line is left for #559.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The id-less message in a mixed batch gets no library id: RSL1k1 needs
every message to have an empty id, and RSL1k3 preserves absent ids as
absent. The inline comment now says so, matching the assertion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RTL6a encodes a realtime publish as RestChannel#publish does, so per
RSL4c3/RSL4d3 an object payload goes on the wire as a JSON string with
encoding "json". Assert that instead of the unstringified object, and
pin useBinaryProtocol: false as the assertions read the wire encoding.

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

This branch was successfully deployed

1 active deployment
staging/pull/537 — 04aed979 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