Skip to content

feat: Retrofit RPC v2 CBOR onto the generic Protocol plugin - #349

Open
jterapin wants to merge 15 commits into
mainfrom
update-cbor-protocol
Open

feat: Retrofit RPC v2 CBOR onto the generic Protocol plugin#349
jterapin wants to merge 15 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

CBOR becomes the first real consumer of the generic Protocol plugin from #348, taking the mechanism live. The old per-service plugin (a plugin, two handlers, and a separate stubber) collapses into one Client::RpcV2Cbor object implementing the 5-method interface.

  • Interface: drop the Protocol base class — it's duck-typed now, documented on NoOpProtocol (which also carries the stubbing methods).
  • Handlers: ParseHandler deserializes success at :build; a separate ErrorHandler runs at :sign, inside the retry loop, so RetryErrors sees modeled retryable errors.
  • Default plugin: Plugins::Protocol is protocol-agnostic (falls back to NoOpProtocol), so it's now a default. The weld only registers the protocol and its dependency.
  • Stubbing: goes through config.protocol instead of a separate :stubber; the protocol object is its own stubber.
  • Registry: an add_protocols weld hook populates client.protocols at codegen, replacing feat: Add generic Protocol plugin and protocol interface #348's test scaffold.
  • Docs: the generated :protocol option now lists the service's supported protocols.

On errors, parse_error ignores anything outside 200..599 (so status-0 transport errors pass through), reads the envelope with a raw decode to get __type, then parses the modeled error through the codec.

Testing

  • smithy-client: 852 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.

Written with AI assistance and reviewed by jterapin.

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 12 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).
Append the service's registered protocols (first is the default) to the
generated :protocol option docstring, so each client lists exactly what
it supports. Emits nothing when no protocol is registered.
Protocols always ship in an installed gem and are required by absolute
path, so the require_relative variant (copied from the plugin view, where
code-generated plugins need it) was dead code. Simplify the protocol view
and require_protocols to emit a plain require.
@jterapin jterapin changed the title [in-progress] feat: Update CBOR protocol feat: Retrofit RPC v2 CBOR onto the generic Protocol plugin Jul 30, 2026
@jterapin
jterapin marked this pull request as ready for review July 31, 2026 16:47
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