Skip to content

Address review comments: type safety and runtime guards#194

Closed
baelter wants to merge 2 commits intomessage-codec-registryfrom
claude/address-review-comments-3hU5w
Closed

Address review comments: type safety and runtime guards#194
baelter wants to merge 2 commits intomessage-codec-registryfrom
claude/address-review-comments-3hU5w

Conversation

@baelter
Copy link
Copy Markdown
Member

@baelter baelter commented Mar 14, 2026

Summary

  • Remove unsafe Serializable overloads from AMQPQueue.publish(), AMQPExchange.publish(), AMQPRPCClient.call(), and AMQPSession.rpcCall() that were accessible on plain (non-codec) sessions, defeating TypeScript compile-time safety
  • Add runtime guard in AMQPSession.encodeBody() that throws a clear error for non-Body values when no codec registry is configured, instead of silently casting with as Body
  • Fix flaky codec callback test by replacing setTimeout(100) polling with promise-based message delivery
  • Fix incorrect CodecMode import path and unsafe type cast in test helper

Test plan

  • TypeScript typecheck passes (npm run typecheck)
  • Unit tests pass (test/amqp-codec-registry.ts)
  • Integration tests pass with broker (test/amqp-session.ts)

https://claude.ai/code/session_013dVmJ9E1SChBtX7oFs3vmb

claude added 2 commits March 14, 2026 05:58
…add runtime guard

- Remove the second `publish(body: Serializable, { contentType })` overload from
  AMQPQueue, AMQPExchange, AMQPRPCClient.call(), and AMQPSession.rpcCall(). These
  overloads were accessible on plain (non-codec) sessions, allowing non-Body values
  to pass type checking but fail at runtime. The `PublishBody<C>` conditional type
  already resolves to `Serializable` for codec sessions, so the first overload
  covers both cases correctly.
- Add a runtime guard in `AMQPSession.encodeBody()` that throws a clear error when
  a non-Body value is passed without a codec registry, instead of silently casting
  with `as Body`.
- Fix flaky codec callback test by replacing `setTimeout(100)` polling with a
  promise that resolves on message delivery.
- Fix incorrect `CodecMode` import path in test file.
- Fix type-unsafe cast in `withCodecSession` test helper.

https://claude.ai/code/session_013dVmJ9E1SChBtX7oFs3vmb
@baelter baelter marked this pull request as draft March 16, 2026 07:58
@baelter
Copy link
Copy Markdown
Member Author

baelter commented Mar 16, 2026

Superseded. Addressing the review feedback directly on the main branch with a simpler approach: dropping the generic from consume-side classes entirely.

@baelter baelter closed this Mar 16, 2026
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.

2 participants