Skip to content

Conversation

yuandrew
Copy link
Contributor

@yuandrew yuandrew commented Mar 24, 2025

What changed?
Added support for proxy interceptors visiting gRPC errors.

Why?
In some scenarios there can be user-provided payloads.
temporalio/sdk-go#1825

How did you test it?
Added new test to validate both these behaviors

Potential risks
Proxy interceptors could completely break?

@yuandrew yuandrew requested review from a team as code owners March 24, 2025 19:34
Comment on lines 103 to 106
stat, ok := status.FromError(err)
if !ok {
return err
}
Copy link
Member

@cretz cretz Mar 26, 2025

Choose a reason for hiding this comment

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

Now that I think about it, I am a tad concerned about this logic because I am concerned that both response and non-status err can be non-nil since technically an interceptor can return an error with a valid response. I think we may still want to apply the logic below the overall err != nil block even on error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This changes existing behavior today, I think it's better if I tackle this in a separate PR with dedicated tests to validate this scenario.

Copy link
Member

Choose a reason for hiding this comment

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

Hrmm, I see we did always eagerly return any error that happened and not affect response. Agreed can be done separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yuandrew yuandrew force-pushed the proxy-grpc-interceptors-grpc-errors branch from aa5ebbe to b333dc5 Compare March 26, 2025 21:32
@yuandrew yuandrew merged commit 051ba8c into temporalio:master Mar 26, 2025
3 checks passed
@yuandrew yuandrew deleted the proxy-grpc-interceptors-grpc-errors branch March 26, 2025 21:34
newStatus := status.New(stat.Code(), stat.Message())
var newDetails []protoadapt.MessageV1
for _, detail := range stat.Details() {
detailAny, ok := detail.(*anypb.Any)
Copy link
Contributor

Choose a reason for hiding this comment

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

What if details contains a proto message that is not any but contains a payload?

Copy link
Member

@cretz cretz Mar 27, 2025

Choose a reason for hiding this comment

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

In theory this should be impossible looking at source, but I agree, we might as well first type assert to message v1, then optionally type assert to any (falling back to just appending the v1 message if it didn't work). also this is large enough that you could consider a private helper in this generated code that does all of this instead of inlining in the interceptor.

Copy link
Contributor

Choose a reason for hiding this comment

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

by "theory this should be impossible looking at source" do you mean the server source or go protobuf?

@@ -478,6 +571,54 @@ func (t *testGRPCServer) PollActivityTaskQueue(
}, nil
}

func (t *testGRPCServer) ExecuteMultiOperation(
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we verify this matches the real output of the server?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, temporalio/temporal#7487 for query, and from our previous discussion it sounded like multi op is not supported yet today?

Copy link
Contributor

Choose a reason for hiding this comment

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

multi op is supported, it is used by update with start

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.

3 participants