Repository navigation
UTS: fix publish-body assertions and pin protocol per test - #537
Open
owenpearson wants to merge 5 commits into
Open
owenpearson wants to merge 5 commits into
owenpearson wants to merge 5 commits into
Conversation
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>
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 was referenced Nov 27, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.mdRSL1apublish-message-array-1: object payload was asserted unstringified; now asserts a stringifieddatastring, decodes it, and assertsencoding == "json"(matching themessage_encoding.mdidiom).channel/publish.mdRSL1enull-name-and-data-0: dropped the whole-body-equality against a literal that omits the idempotencyid(RSL1k1); now asserts field-wise plus the existingNOT INomission checks.channel/idempotency.mdRSL1kmixed-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.mdRTL6i1publish-message-object-1(from the Three REST publish-body assertions contradictfeatures.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 asRestChannel#publishdoes, so the test now assertsdata IS String,parse_json(data) == {"key": "value"}andencoding == "json", with the protocol pinned to JSON.Protocol pinned per test
useBinaryProtocoldefaults totrue(TO3f), soparse_json(request.body)only holds under JSON. AddeduseBinaryProtocol: falseto the client in every unit section that reads the request body or asserts on its encoding:features.md(RSL4c3/RSL4d3, RSL1k1, RSL1k3), and eight unit specs read the request body without pinning the protocol #527;auth/revoke_tokens.md: the seven sections thatJSON_PARSEthe request body (RSA17b_1/2, RSA17e_1/2, RSA17f_1/2/3);batch_publish.md: every section that inspects the captured body (RSC22c1, RSC22c2, RSC22c6, the three RSC22d sections, BSP2a, BSP2b, RSC22_Batch1), plus RSC22_Headers1, which assertsContent-Type: application/json. RSC22c6 needs it so the base64/encoding: "base64"branch is valid.A grep of every
parse_json/JSON_PARSE/json_decodeof a request body underuts/rest/unit,uts/realtime/unitanduts/objects/unitnow finds none outside a pinned section. The batch response shapes andX-Ably-Version: 2inbatch_publish.md/revoke_tokens.mdare #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 pinuseBinaryProtocol(citingmessage_encoding.mdas 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 bareencoding: "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.mduts/rest/unit/channel/publish.mduts/rest/unit/channel/idempotency.mduts/rest/unit/channel/annotations.mduts/rest/unit/channel/update_delete_message.mduts/rest/unit/batch_publish.mduts/rest/unit/auth/revoke_tokens.mduts/rest/unit/push/push_admin_publish.mduts/rest/unit/push/push_channels.mduts/rest/unit/push/push_channel_subscriptions.mduts/rest/unit/push/push_device_registrations.mduts/realtime/unit/channels/channel_publish.mdMerge order
PR 3 of 7. Merge after the mock-HTTP PR. Shares
channel/idempotency.mdwith the spec-point-references PR andencoding/message_encoding.mdwith the broken-fixtures PR, so coordinate/rebase.Part of #527
🤖 Generated with Claude Code