Skip to content

Conversation

@natemort
Copy link
Member

Proto objects throw a NullPointerException if you pass a null value into any setFoo method. Our current mappers make strong assumptions about what fields are and aren't necessary, and any time they don't match either the server or the client logic we get a vague NullPointerException.

Instead, map all objects and don't assume that any field is non-null. The server or client should enforce the validity of the requests rather than the mapper.

Additionally don't mutate Maps that we receive from Thrift/Proto in WorkflowContext.

What changed?

  • Eliminate potential NullPointerExceptions from ProtoMappers
  • Don't mutate Maps from Thrift/Proto in WorkflowContext.

Why?

  • Improve gRPC compatibility for some edge cases where the Server/client disagree on which fields are mandatory.
  • Correct Workflow processing issue with search attributes.

How did you test it?

  • Unit/Integration tests and running our validation suite for 24 hours.

Potential risks

  • It's possible that there are additional edge cases not covered here or that these changes themselves introduce a bug outside of the core functionality that our integration/validation tests cover.

Release notes

Documentation Changes

Proto objects throw a NullPointerException if you pass a null value into any setFoo method. Our current mappers make strong assumptions about what fields are and aren't necessary, and any time they don't match either the server or the client logic we get a vague NullPointerException.

Instead, map all objects and don't assume that any field is non-null. The server or client should enforce the validity of the requests rather than the mapper.

Additionally don't mutate Maps that we receive from Thrift/Proto in WorkflowContext.
.setWorkflowExecution(TypeMapper.workflowRunPair(t.getWorkflowID(), t.getRunID()))
.setActivityId(t.getActivityID())
.setDetails(payload(t.getDetails()));
.setWorkflowExecution(TypeMapper.workflowRunPair(t.getWorkflowID(), t.getRunID()));
Copy link
Member

Choose a reason for hiding this comment

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

do we need nil check for wfID and runID?

Copy link
Member Author

Choose a reason for hiding this comment

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

Those are handled within the workflowRunPair method. If they're null the field in the WorkflowExecution will be empty.

Copy link
Member

@timl3136 timl3136 left a comment

Choose a reason for hiding this comment

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

left a quick question regarding the nil check ^

@natemort natemort merged commit 4d2f165 into cadence-workflow:v3.13.x Nov 18, 2025
6 checks passed
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