Skip to content

Comments

Improve error model and serialization#69

Merged
bergundy merged 8 commits intomainfrom
error-model-improvements
Feb 11, 2026
Merged

Improve error model and serialization#69
bergundy merged 8 commits intomainfrom
error-model-improvements

Conversation

@pdoerner
Copy link
Contributor

@pdoerner pdoerner commented Dec 5, 2025

  • 💥 BREAKING CHANGE 💥 Removes the experimental FailureConverter interface.
  • Enhances HandlerError, OperationError, and FailureError to support separate Cause and Message fields as well as StackTrace.
  • Deprecates HandlerErrorf in favor of NewHandlerErrorf.
  • Deprecates OperationErrorf, OperationCanceledErrorf, OperationFailedErrorf, NewOperationFailedError, NewOperationCanceledError in favor of NewOperationErrorf, NewOperationFailedErrorf and NewOperationCanceledErrorf.

Revives the work from #56 and #65

nexus/failure.go Outdated
// By default the SDK translates [HandlerError], [OperationError] and [FailureError] to and from [Failure]
// objects maintaining their cause chain.
// Arbitrary errors are translated to a [Failure] object with its Message set to the Error() string, losing the cause
// chain.
Copy link
Contributor

Choose a reason for hiding this comment

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

Might as well mark it as experimental since it's not exposed to Temporal applications yet.

Suggested change
// chain.
// chain.
//
// NOTE: Experimental

@bergundy
Copy link
Contributor

bergundy commented Dec 5, 2025

Just please don't merge this until we've validated the changes.
I would consider removing the failure converter out of this repo entirely FWIW since it's only used where the protocol is implemented.

@pdoerner pdoerner marked this pull request as ready for review December 16, 2025 18:23
@pdoerner pdoerner requested a review from a team as a code owner December 16, 2025 18:23
nexus/failure.go Outdated
// The underlying Failure object this error represents.
Failure Failure
// An optional nested cause.
Cause error
Copy link
Contributor

Choose a reason for hiding this comment

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

Failure also has a Cause, do we need two different causes? What scenario would both be set?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the deserialized cause.

nexus/api.go Outdated
// construct the cause.
// OperationFailedErrorf creates an [OperationError] with state set to [OperationStateFailed], using [fmt.Sprintf] to
// construct the message.
func OperationFailedErrorf(format string, args ...any) *OperationError {
Copy link
Contributor

Choose a reason for hiding this comment

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

This breaks error chaining no? if args was an error this used to preserve the error chain and now no longer does.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same goes for HandlerErrorf

Copy link
Contributor

Choose a reason for hiding this comment

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

That was accidentally committed. I meant to revert back to the old implementations. Looks like I missed a couple.

nexus/api.go Outdated
// The underlying cause for this error.
Cause error
// Set if this error is constructed from a failure object.
OriginalFailure *Failure
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we didn't need this anymore since since we are using application failures?

Copy link
Contributor

Choose a reason for hiding this comment

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

Still required for the server to rehydrate the original failure.

@bergundy bergundy force-pushed the error-model-improvements branch from 3d8ad6d to e5df0cd Compare February 10, 2026 01:16
nexus/errors.go Outdated
)

// An error that directly represents a wire representation of [Failure].
// The SDK will convert to this error by default unless the [FailureConverter] instance is customized.
Copy link
Contributor

Choose a reason for hiding this comment

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

[FailureConverter] no longer exists in the Nexus SDK right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!

// OperationFailedErrorf creates an [OperationError] with state set to [OperationStateFailed], using [fmt.Errorf] to
// construct the cause.
//
// Deprecated: Use NewOperationFailedErrorf instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

If we aren't synchronizing the release of the Nexus SDK with the Temporal Go SDK may not want to deprecate these until the Go SDK that supports causless operation errors is released

@bergundy bergundy merged commit 26b0b4c into main Feb 11, 2026
3 checks passed
@bergundy bergundy deleted the error-model-improvements branch February 11, 2026 05:16
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