Skip to content

fix(grpc): decode errors in streaming Recv() methods#3731

Merged
raphael merged 2 commits into
v3from
fix/grpc-stream-error-decoding
Jun 30, 2025
Merged

fix(grpc): decode errors in streaming Recv() methods#3731
raphael merged 2 commits into
v3from
fix/grpc-stream-error-decoding

Conversation

@raphael
Copy link
Copy Markdown
Member

@raphael raphael commented Jun 25, 2025

This commit fixes issue #3320 where gRPC streaming Recv() methods were not
decoding errors properly, unlike unary methods which correctly decode custom
error types.

Changes:

  • Updated stream_recv.go.tpl template to add error decoding for client streaming
  • Added DecodeError call and type switching for custom errors
  • Added validation for custom errors that have validation rules
  • Fixed code generation issues (indentation and argument passing)

The fix ensures consistent error handling between unary and streaming gRPC
methods, allowing clients to properly handle custom service errors defined
in the DSL for all streaming patterns (server, client, and bidirectional).

Tests added to verify:

  • Custom errors are properly decoded in streaming recv methods
  • Validation is applied to custom errors
  • All streaming patterns handle errors consistently

Fixes #3320

  This commit fixes issue #3320 where gRPC streaming Recv() methods were not
  decoding errors properly, unlike unary methods which correctly decode custom
  error types.

  Changes:
  - Updated stream_recv.go.tpl template to add error decoding for client streaming
  - Added DecodeError call and type switching for custom errors
  - Added validation for custom errors that have validation rules
  - Fixed code generation issues (indentation and proper template usage)

  The fix ensures consistent error handling between unary and streaming gRPC
  methods, allowing clients to properly handle custom service errors defined
  in the DSL for all streaming patterns (server, client, and bidirectional).

  Tests added to verify:
  - Custom errors are properly decoded in streaming recv methods
  - Validation is applied to custom errors
  - All streaming patterns handle errors consistently
  - Error handling is consistent between unary and streaming methods

  Fixes #3320
@raphael raphael force-pushed the fix/grpc-stream-error-decoding branch from 45bb296 to 707f223 Compare June 25, 2025 22:19
@raphael raphael merged commit 21839d6 into v3 Jun 30, 2025
9 checks passed
@raphael raphael deleted the fix/grpc-stream-error-decoding branch June 30, 2025 18:18
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.

grpc stream.Recv doesn't decode errors

1 participant