[in-progress] feat: Update CBOR protocol - #349
Draft
jterapin wants to merge 13 commits into
Draft
Conversation
Drop the base class in favor of a duck-typed interface documented on the standalone NoOpProtocol. Parse handlers now get context, so a protocol can reach request headers and operation errors.
One RpcV2Cbor object replaces the per-service plugin, its two handlers, and the separate stubber. Stubbing runs through config.protocol (the object doubles as its own stubber). AWS protocols follow in a separate PR, so their stubbing stays red on version-4 until then.
jterapin
force-pushed
the
update-cbor-protocol
branch
from
July 24, 2026 18:29
dbcb3a9 to
bddc3d2
Compare
Consolidate the build_request examples with aggregate_failures and merge the two returns-nil cases. Strengthen error assertions to check the resolved error class/code and a parsed field (not just StandardError), and round-trip stubbed data through the codec. Reuse NoOpProtocol as the resolution test double.
Qualify the bare Cbor constant to Smithy::Cbor for clarity and to avoid ambiguity if a Smithy::Client::Cbor is ever introduced. Add a comment explaining why extract_error uses a raw decode (to read __type before the modeled error shape is known) rather than the schema-aware codec. Drop a stale comment referencing the old ErrorHandler.
Add explanatory comments to the protocol codegen views and weld registry. Remove the now-redundant Protocol plugin add in the stub responses interface spec (it is a default plugin), keeping the registry override with a comment on why the Shapes fixture still needs it.
Drop the brittle error class-name checks (error.code already identifies the resolved error) and inline the single-use sample_client let into the client let.
Remove the self-evident status-range comment on parse_error. Expand the stub responses spec comment to explain why the fake protocol registry is needed (NoOpProtocol's stubbing is a no-op, so the assertions would fail without it).
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.
Issue
Follows #348 (generic Protocol plugin, define-only). That PR added the mechanism but nothing consumed it. CBOR was still served by a per-service plugin (
Plugins::RpcV2Cbor) with its serialization split across two handler classes and a separate stubber, none of which used the new interface.Description
Retrofit RPC v2 CBOR onto the generic Protocol plugin, making it the first real consumer and taking the mechanism live:
Client::RpcV2Cborreplaces the old plugin, its two handlers (Handler+ErrorHandler), and the separate CBOR stubber, implementing the 5-method interface (build_request/parse_data/parse_error/stub_data/stub_error).Protocolbase class; the interface is now duck-typed and documented on the standaloneNoOpProtocol, which also carries the stubbing methods.ParseHandlerdeserializes successful responses at the:buildstep (once, outside the retry loop). A dedicatedErrorHandlerruns at the:signstep, inside the retry loop, soresponse.erroris populated beforeRetryErrorsinspects it — otherwise modeled retryable/throttling errors would never trigger a retry. Both handlers delegate toconfig.protocol; the protocol owns all status-range and error-vs-success logic.Plugins::Protocolis protocol-agnostic (resolves toNoOpProtocolwhen nothing is registered), so it now ships as a default plugin. The Protocols weld only contributes the protocol registry entry and its runtime dependency, not the plugin itself.config.protocolinstead of a separate:stubberoption; the protocol object doubles as its own stubber.add_protocolsweld hook populatesclient.protocolsat codegen, replacing the test-only registry scaffold from feat: Add generic Protocol plugin and protocol interface #348.parse_errorreproduces the oldErrorHandler'son_done(200..599)gate with an early return, so signaled transport errors (status 0) pass through untouched. Error data is deserialized through the protocol's configured codec (@codec), consistent with the success path.Testing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.