-
Notifications
You must be signed in to change notification settings - Fork 272
Introduce SDK flag to use user DC on Memo's #2121
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| // memoUserDCEncode exists to allow us to configure the default behavior of | ||
| // SDKFlagMemoUserDCEncode. This is primarily useful with tests. | ||
| var memoUserDCEncode = os.Getenv("MEMO_USER_DC_ENCODE") != "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says this is useful for tests, but I don't see this used in the SDK anywhere. Why did we need to add this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's set and used in SetMemoUserDCEncode(), so we can defer setting it back to its previous flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as well as configuring the default behavior for tests, so we can validate both the old and new behavior
| SDKFlagUnknown = math.MaxUint32 | ||
| // SDKFlagMemoUserDCEncode will use the user data converter when encoding a memo. If user data converter fails, | ||
| // we will fallback onto the default data converter. If the default DC fails, the user DC error will be returned. | ||
| SDKFlagMemoUserDCEncode = 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my confirmation (didn't review whole PR or anything), this flag will now be set for any workflow that uses UpsertMemo or ExecuteChildWorkflow but not for any other workflows? But for now this is off by default unless the MEMO_USER_DC_ENCODE env var is set? And I presume one day we'll just turn it on for all users (i.e. change var memoUserDCEncode = os.Getenv("MEMO_USER_DC_ENCODE") != "" to os.Getenv("MEMO_USER_DC_ENCODE") != "false" or something)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this flag will now be set for any workflow that uses UpsertMemo or ExecuteChildWorkflow but not for any other workflows
What do you mean "not for any other workflows"? My understanding is this should be set for all workflows, regardless of if they use UpsertMemo or ExecuteChildWorkflow.
And I presume one day we'll just turn it on for all users (i.e. change var memoUserDCEncode = os.Getenv("MEMO_USER_DC_ENCODE") != "" to os.Getenv("MEMO_USER_DC_ENCODE") != "false" or something)?
Correct, one day we will flip the switch to turn it on by default. iirc server needs a version or 2 to fall back onto, so we want to wait a bit before flipping the switch on a new SDK flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean "not for any other workflows"? My understanding is this should be set for all workflows, regardless of if they use UpsertMemo or ExecuteChildWorkflow.
When I looked at when .TryUse(SDKFlagMemoUserDCEncode) was invoked, it was only in those two situations, but I may be misreading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh no I think you're right, but does it matter if we set the SDK flag if our workflow isn't exercising Memo code? I wanna say no. The flag is primarily for replaying and ensuring this fix doesn't cause NDE with pre-fix histories
What was changed
Introduced an SDK flag,
SDKFlagMemoUserDCEncode, to configure new behavior, where we actually use the user data converter when encoding Memo's. If user DC errors out, the default DC will be used as a fallback. If that also returns an error, the user DC error will be returned to the caller.SDK flag is still set to false by default, so no behavior changes. After a Go SDK release or two, will the flag then be enabled by default.
Why?
Correct behavior to match other SDKs
Checklist
Closes Memo does not go through user provided data coverter #1045
How was this tested:
Added new tests that flip on/off the SDK flag and validates behavior
Any docs updates needed?
Note
Adds SDKFlagMemoUserDCEncode to optionally encode workflow/schedule memos with the user data converter (falling back to default), and updates codepaths and tests to honor it.
SDKFlagMemoUserDCEncodewith env toggleMEMO_USER_DC_ENCODEand setterSetMemoUserDCEncode.encodeMemoValueandshouldUseMemoUserDataConverter; prefer userDataConverterfor memo encoding, fallback to default on error.getWorkflowMemo(..)andvalidateAndSerializeMemo(..)to accept amemoFlagAccessorand apply flag.StartWorkflow,SignalWithStart, child workflow start, schedules, testsuite) to pass accessor and/or use new helpers.encodeScheduleWorkflowMemonow uses user DC (with fallback) and defaults DC when nil.Written by Cursor Bugbot for commit 049d0fb. This will update automatically on new commits. Configure here.