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

Refactor failWorkflowTask method #3915

Merged
merged 1 commit into from
Feb 8, 2023

Conversation

alexshtin
Copy link
Member

@alexshtin alexshtin commented Feb 8, 2023

What changed?
Rename failCommand to failWorkflowTask because it fails workflow task not command and extract other methods to better code reuse.

Why?
To reuse code to fail workflow task in different places.

How did you test it?
Existing tests.

Potential risks
No risks.

Is hotfix candidate?
No.

return handler.failWorkflowTaskOnInvalidArgument(validationFn())
}

func (handler *workflowTaskHandlerImpl) failWorkflowTaskOnInvalidArgument(
Copy link
Member

Choose a reason for hiding this comment

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

why we need this method? can we just call failWorkflowTask(wtFailedCause, err) in places where you need this method?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's to distinguish an error from user input vs an internal error?
cc: @alexshtin

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't want to change any logic in "refactor" style PR. But yes, having both of them is not right. I was thinking about reverse approach: calling failWorkflowTaskOnInvalidArgument everywhere where failWorkflowTask is called now. Wrong "user" input should fail WT but any server errors should not. I need to track all possible errors here to make a call and it is out of scope for this small refactoring.

Copy link
Collaborator

@rodrigozhou rodrigozhou left a comment

Choose a reason for hiding this comment

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

You're not changing the error handling for UnaliasFields call?

return handler.failWorkflowTaskOnInvalidArgument(validationFn())
}

func (handler *workflowTaskHandlerImpl) failWorkflowTaskOnInvalidArgument(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's to distinguish an error from user input vs an internal error?
cc: @alexshtin

wtFailedCause = NewWorkflowTaskFailedCause(enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_BINARY, serviceerror.NewInvalidArgument(fmt.Sprintf("binary %v is already marked as bad deployment", request.GetBinaryChecksum())))
wtFailedCause = newWorkflowTaskFailedCause(
enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_BINARY,
serviceerror.NewInvalidArgument(fmt.Sprintf("binary %v is already marked as bad deployment", request.GetBinaryChecksum())),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
serviceerror.NewInvalidArgument(fmt.Sprintf("binary %v is already marked as bad deployment", request.GetBinaryChecksum())),
serviceerror.NewInvalidArgument(
fmt.Sprintf(
"binary %v is already marked as bad deployment",
request.GetBinaryChecksum(),
),
),

Copy link
Member Author

Choose a reason for hiding this comment

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

and I believe word "already" doesn't belong here.

Copy link
Collaborator

@rodrigozhou rodrigozhou left a comment

Choose a reason for hiding this comment

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

LGTM, just a nit comment.

@alexshtin
Copy link
Member Author

You're not changing the error handling for UnaliasFields call?

Not in this one. Stay tuned :-)

@alexshtin alexshtin enabled auto-merge (squash) February 8, 2023 17:40
@alexshtin alexshtin merged commit 9e37fec into temporalio:master Feb 8, 2023
@alexshtin alexshtin deleted the refactor/fail-wt branch February 8, 2023 18:34
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