Skip to content
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

Merged
merged 3 commits into from
Oct 3, 2024

Conversation

stephanos
Copy link
Contributor

@stephanos stephanos commented Oct 2, 2024

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

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?

@@ -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
Copy link
Contributor Author

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")
Copy link
Contributor Author

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.

@stephanos stephanos marked this pull request as ready for review October 2, 2024 22:47
@stephanos stephanos requested a review from a team as a code owner October 2, 2024 22:47
@stephanos stephanos changed the title Error for unused operation Error for unused Update operation Oct 2, 2024
@@ -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"))
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@stephanos stephanos enabled auto-merge (squash) October 3, 2024 18:29
@stephanos stephanos merged commit 4e8380c into temporalio:master Oct 3, 2024
13 checks passed
@stephanos stephanos deleted the multiops-unused-err branch October 3, 2024 19:12
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