Skip to content

Add payload validation exception factory - #853

Open
bergundy wants to merge 1 commit into
temporalio:mainfrom
bergundy:payload-validation-exception
Open

Add payload validation exception factory#853
bergundy wants to merge 1 commit into
temporalio:mainfrom
bergundy:payload-validation-exception

Conversation

@bergundy

Copy link
Copy Markdown
Member

Payload converters and codecs can use this to report invalid Nexus operation input with structured details.

@bergundy
bergundy requested a review from a team as a code owner August 20, 2026 22:30
/// Factory for application failures that report invalid Nexus operation input from payload
/// conversion.
/// </summary>
public static class PayloadValidationException

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is not an exception class, so it should not be named *Exception. I would suggest renaming to PayloadValidationError and renaming the factory method to CreateException. Please update the change log to reflect this change too.

@@ -0,0 +1,31 @@
#pragma warning disable CA1711 // Factory naming matches the payload validation API across SDKs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This pragma will not be needed once the rename occurs.

"Payload validation failed",
errorType: ErrorType,
nonRetryable: true,
details: details == null ? Array.Empty<object?>() : new object?[] { details });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Every other SDK is producing one detail object unconditionally, regardless of details being null / None. Either this should match or the other SDKs corrected.

@@ -144,6 +136,6 @@ public NexusPayloadSerializer(DataConverter dataConverter) =>
private static bool IsPayloadValidationFailure(Exception e) =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would recommend moving this to PayloadValidationError as an internal method. Since it creates the validation exception, it should also decide whether something is a validation exception or not.

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