-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error for unused Update operation #1655
Conversation
c596400
to
2c8a4a5
Compare
2c8a4a5
to
88e19cd
Compare
@@ -746,7 +746,7 @@ type ( | |||
// workflow completion callback. Only settable by the SDK - e.g. [temporalnexus.workflowRunOperation]. | |||
callbacks []*commonpb.Callback | |||
// links. Only settable by the SDK - e.g. [temporalnexus.workflowRunOperation]. | |||
links []*commonpb.Link | |||
links []*commonpb.Link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh? Seems correct now.
require.NoError(s.T(), err) | ||
|
||
_, err = updOp.Get(ctxWithTimeout) | ||
require.EqualError(s.T(), err, "context deadline exceeded: operation was not executed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming the cause of the deadline should be on the right.
internal/client.go
Outdated
@@ -1082,6 +1082,9 @@ func (op *UpdateWithStartWorkflowOperation) Get(ctx context.Context) (WorkflowUp | |||
case <-op.doneCh: | |||
return op.handle, op.err | |||
case <-ctx.Done(): | |||
if !op.executed.Load() { | |||
return nil, fmt.Errorf("%v: %v", ctx.Err(), fmt.Errorf("operation was not executed")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for error wrapping shouldn't one of these be a %w
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed! I just learned that Go 1.20 supports multiple %w
, changing it to that now.
What was changed
When the request for the update operation's handle times out, it now returns a more specific error if the operation was never actually executed as part of a MultiOperation.
Why?
It's easy to forget to specify
WithStartOperation
(happened to me when I worked on a Go sample). This signals more clearly to the user that they forgot to run it. However, IMO the error cannot be more specific than that, since there could be other reasons why the operation was never executed.Checklist
Closes
How was this tested: