Skip to content

[in-progress] feat: Update CBOR protocol - #349

Draft
jterapin wants to merge 13 commits into
mainfrom
update-cbor-protocol
Draft

[in-progress] feat: Update CBOR protocol #349
jterapin wants to merge 13 commits into
mainfrom
update-cbor-protocol

Conversation

@jterapin

@jterapin jterapin commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

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:

  • One protocol object. A standalone Client::RpcV2Cbor replaces 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).
  • Interface cleanup. Drop the Protocol base class; the interface is now duck-typed and documented on the standalone NoOpProtocol, which also carries the stubbing methods.
  • Split parse and error handling. ParseHandler deserializes successful responses at the :build step (once, outside the retry loop). A dedicated ErrorHandler runs at the :sign step, inside the retry loop, so response.error is populated before RetryErrors inspects it — otherwise modeled retryable/throttling errors would never trigger a retry. Both handlers delegate to config.protocol; the protocol owns all status-range and error-vs-success logic.
  • Protocol plugin is a default. The generic Plugins::Protocol is protocol-agnostic (resolves to NoOpProtocol when 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.
  • Stubbing through the protocol. Stubbing routes through config.protocol instead of a separate :stubber option; the protocol object doubles as its own stubber.
  • Real registry. A new add_protocols weld hook populates client.protocols at codegen, replacing the test-only registry scaffold from feat: Add generic Protocol plugin and protocol interface #348.

parse_error reproduces the old ErrorHandler's on_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

  • smithy-client: 857 examples, 0 failures, 2 pending
  • smithy unit: 505, 0 failures
  • generated CBOR protocol tests: 113, 0 failures
  • RuboCop clean

Note: AWS protocols still use a String :protocol + a separate :stubber and are migrated in a follow-up PR.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

jterapin added 3 commits July 24, 2026 11:28
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
jterapin force-pushed the update-cbor-protocol branch from dbcb3a9 to bddc3d2 Compare July 24, 2026 18:29
@jterapin jterapin changed the title TBD feat: Update CBOR protocol Jul 24, 2026
@jterapin jterapin changed the title feat: Update CBOR protocol [in-progress] feat: Update CBOR protocol Jul 24, 2026
jterapin added 10 commits July 27, 2026 12:34
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant