Skip to content

gorums: harden message unmarshaling and address stream review findings - #340

Merged
meling merged 5 commits into
refactor/stream-simplificationfrom
fix/message-helpers-and-review
Oct 7, 2026
Merged

meling merged 5 commits into
refactor/stream-simplificationfrom
fix/message-helpers-and-review

Conversation

@meling

@meling meling commented Oct 3, 2026

Copy link
Copy Markdown
Member
  • internal/impl: move request unmarshaling next to response unmarshaling, and reject method names that do not name a method. A peer's reply carrying a message, enum, service, or field name made the caller panic on an unchecked type assertion; registry errors are now wrapped with %w.
  • internal/conn: NewInboundManager returns invalid peer configuration errors, so NewLocalServers reports them instead of panicking.
  • stream: document that requeued calls are bounded by the send queue, and when expired pending calls are removed.

Stack created with GitHub Stacks CLI • Give Feedback 💬

Copilot AI balanced review requested due to automatic review settings October 3, 2026 20:48
@meling
meling added this pull request to stack #338 October 3, 2026 20:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation consistently propagates errors, prevents unsafe descriptor assertions, and includes focused regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Hardens protobuf unmarshaling against invalid method descriptors, propagates peer configuration failures safely, and clarifies stream retry behavior.

Changes:

  • Validates method descriptors and preserves registry errors.
  • Returns inbound peer configuration errors instead of panicking.
  • Documents pending-call cleanup and bounded requeue behavior.
File Description
server.go Handles inbound-manager errors and uses shared unmarshaling.
server_handler.go Removes duplicated request unmarshaling.
local_servers_test.go Tests invalid peer error propagation.
internal/​stream/​session.go Clarifies session and retry behavior.
internal/​stream/​pending.go Documents expired-call removal.
internal/​stream/​outbound.go Documents reconnect and requeue semantics.
internal/​stream/​channel.go Clarifies pending-count behavior.
internal/​impl/​marshaling.go Centralizes safe request/response unmarshaling.
internal/​impl/​marshaling_test.go Tests valid, missing, and non-method descriptors.
internal/​conn/​inbound_manager.go Returns peer configuration errors.
internal/​conn/​inbound_manager_test.go Updates constructor and error-path tests.
doc/​dev-guide.md Documents send-queue-bounded requeueing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@meling
meling force-pushed the fix/message-helpers-and-review branch 2 times, most recently from e93b8c7 to b9be560 Compare October 3, 2026 22:49
@meling
meling force-pushed the fix/message-helpers-and-review branch from b9be560 to 9b32628 Compare October 4, 2026 09:44
@meling
meling force-pushed the fix/message-helpers-and-review branch from 9b32628 to 8c99e28 Compare October 4, 2026 14:42
meling added 5 commits October 7, 2026 19:55
UnmarshalRequest and unmarshalResponse look up the method descriptor
the same way, so they belong in one file. The function moves unchanged;
the server calls it through internal/impl.
Request and response unmarshaling resolve the message type from the
method name carried on the wire, and asserted that the registry lookup
returned a method descriptor. A name that resolves to a message, enum,
service, or field made the assertion panic. A response reaches this path
before any handler lookup, so a peer could crash a caller with one frame.

Both directions now share one helper that checks the assertion and wraps
registry errors with %w, so callers can match protoregistry.NotFound.
NewInboundManager panicked when its NodeSource rejected an address or a
duplicate node. newServer builds the inbound manager before the peer
configuration it already checks, so NewLocalServers panicked on such
peers instead of returning the error it documents. NewInboundManager now
returns the error, and newServer passes it on; NewServer still panics.
Calls pending on a failed stream are pushed onto the send queue without
waiting, so once it is full the rest fail with ErrSendQueueFull. The
OutboundChannel and retry docs promised that every non-streaming call is
sent again; they now state the bound and list each case in which retry
fails a call. The session docs also explain how a session relates to the
gRPC stream it runs on and to the channel's other sessions.
A pending call whose caller is done is removed by a sweep when a later
call grows the table, or by its own context watch once the stream starts
draining. After a burst, calls that expired since the last sweep keep
their memory and count in PendingCount until a later sweep or the end of
the stream. The docs now say so.
@meling
meling force-pushed the fix/message-helpers-and-review branch from 8c99e28 to 8365870 Compare October 7, 2026 18:16
@meling
meling merged commit 90a30cc into master Oct 7, 2026
6 checks passed
@meling
meling deleted the fix/message-helpers-and-review branch October 7, 2026 18:33
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