Skip to content
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

Allow JSONProtoPayloadConverter to accept ignore_unknown_fields as an optional argument #365

Merged
merged 2 commits into from
Aug 16, 2023

Conversation

william-almy-skydio
Copy link
Contributor

@william-almy-skydio william-almy-skydio commented Aug 7, 2023

What was changed

This commit enables the JSONProtoPayloadConverter to accept ignore_unknown_fields as an optional argument so that we can utilize this functionality when converting proto to json.

Why?

When deploying multiple services out-of-sync with Temporal, proto fields may change in a way that would not necessarily cause the workflow to fail, however without setting the ignore_unknown_fields option above, otherwise backwards-compatible proto changes result in conversion errors. As mentioned in the linked issue below, "People may want to ignore unknown fields and right now they have to remake the class themselves"

Checklist

  1. Closes [Feature Request] Support constructing JSONProtoPayloadConverter with google.protobuf.json_format.Parse options #315

  2. How was this tested:

  • Spinning up a worker / workflow that accept an initial version of proto args
  • Changing the proto definition in the client triggering the workflow to include an additional field
  • Triggering the workflow with the newer version of proto args, while worker/workflow use older version
  • Verifying the workflow converts the args and completes successfully
  1. Any docs updates needed?

@CLAassistant
Copy link

CLAassistant commented Aug 7, 2023

CLA assistant check
All committers have signed the CLA.

@william-almy-skydio william-almy-skydio marked this pull request as ready for review August 7, 2023 21:04
@william-almy-skydio william-almy-skydio requested a review from a team as a code owner August 7, 2023 21:04
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.

This is great, thanks! One minor change and we should be good.

@@ -388,6 +388,16 @@ def from_payload(
class JSONProtoPayloadConverter(EncodingPayloadConverter):
"""Converter for 'json/protobuf' payloads supporting protobuf Message values."""

def __init__(self, ignore_unknown_fields: Optional[bool] = False):
Copy link
Member

@cretz cretz Aug 8, 2023

Choose a reason for hiding this comment

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

Suggested change
def __init__(self, ignore_unknown_fields: Optional[bool] = False):
def __init__(self, ignore_unknown_fields: bool = False):

(can run poe lint-types to confirm types or just poe lint to confirm all is well in general)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you!

@cretz cretz merged commit 31358d1 into temporalio:main Aug 16, 2023
11 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
3 participants