Skip to content

Conversation

stephanos
Copy link
Contributor

@stephanos stephanos commented Jun 20, 2025

What changed?

Added Aborted serviceerror.

Why?

There's a need to return an Aborted serviceerror from the server.

Given that we these serviceerror types for each status code, it seems like the right thing to add this here.

How did you test it?

Potential risks

@stephanos stephanos force-pushed the serviceerror-aborted branch from 9afcfc0 to 6e9b4ad Compare June 20, 2025 19:45
@stephanos stephanos marked this pull request as ready for review June 20, 2025 20:16
@stephanos stephanos requested review from a team as code owners June 20, 2025 20:16
@@ -94,7 +94,7 @@ func FromStatus(st *status.Status) error {
case *failure.MultiOperationExecutionAborted:
return newMultiOperationAborted(st)
default:
// fall through to st.Err()
return newAborted(st)
Copy link
Contributor

@ychebotarev ychebotarev Jun 20, 2025

Choose a reason for hiding this comment

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

not an issue.
It looks like the only different between those errors (like return newUnavailable(st)) is the name of the structure, and the rest is the same.
Any specific reason we choose this approach instead of "newErrorWithCode" or something like that, that looks like

ErrorWithCode struct {
		Message string
                 Code  codes.Code
		st      *status.Status
	}

and then other "concrete" errors inherits from it? This way we may avoid reflection, and reduce number of error types.

Copy link
Member

@cretz cretz Jun 23, 2025

Choose a reason for hiding this comment

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

and then other "concrete" errors inherits from it? This way we may avoid reflection, and reduce number of error types.

Go doesn't have inheritance, and if embedding this like type Aborted struct { ErrorWithCode } you aren't reducing the number of error types, and not sure what is meant by reflection here. The duplication here is fairly normal in these cases.

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Nothing technically blocking

@@ -94,7 +94,7 @@ func FromStatus(st *status.Status) error {
case *failure.MultiOperationExecutionAborted:
return newMultiOperationAborted(st)
default:
// fall through to st.Err()
return newAborted(st)
Copy link
Member

Choose a reason for hiding this comment

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

I am (only slightly) concerned this may be technically incompatible behavior changing an error type that users may be using. Can we make sure that this is clearly called out in the release notes of the next release of this repo?

Copy link
Contributor Author

@stephanos stephanos Jun 23, 2025

Choose a reason for hiding this comment

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

Right; I also thought about that for a bit.

From what I understand, the purpose of FromStatus is to convert status.Status to a particular type of service error; or fallback to status.Error if there isn't one available.

An incompatibility issue would occur if a user
(1) relied on the error message details (.Error()) or
(2) tried to cast the result to a status.Error

Both seem unlikely, but definitely technically possible.

👍 I can add a warning to the release notes.

@@ -94,7 +94,7 @@ func FromStatus(st *status.Status) error {
case *failure.MultiOperationExecutionAborted:
return newMultiOperationAborted(st)
default:
// fall through to st.Err()
return newAborted(st)
Copy link
Member

Choose a reason for hiding this comment

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

What about out of range and unauthenticated? Should we do those now too or wait?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. I'm not sure tbh. Doing it now batches the "breaking" changes; but we might also never change this.

Generally, I understand this method to act as "try to parse this status to a typed error so I can extract error details". If the status cannot be converted, I wouldn't expect users to use/expect the status.Error since it doesn't add anything over status.Status. But they still might ...

@stephanos stephanos merged commit 4bd288b into temporalio:master Jun 23, 2025
4 checks passed
@stephanos stephanos deleted the serviceerror-aborted branch June 23, 2025 22:27
yycptt pushed a commit that referenced this pull request Aug 4, 2025
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