Skip to content

Conversation

@spkane31
Copy link
Contributor

@spkane31 spkane31 commented Jul 17, 2025

What changed?

BatchWorkflow now supports resetting activities and updating options.

Why?

Support future cli work to support temporal activity {batch,update-options} --query ...

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

Potential risks

This does not change previous behavior

@spkane31 spkane31 requested a review from a team as a code owner July 17, 2025 18:00
Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

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

Didn't take a close look at the tests, left some comments about the implementation.

go.mod Outdated
go.opentelemetry.io/otel/sdk/metric v1.34.0
go.opentelemetry.io/otel/trace v1.34.0
go.temporal.io/api v1.50.1-0.20250715164317-6157f960f13b
go.temporal.io/api v1.50.1-0.20250717214050-28ae23500a33
Copy link
Member

Choose a reason for hiding this comment

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

Please merge the API change before the server PR.

WorkflowId: workflowID,
RunId: runID,
},
// QUESTION: do we want to plumb through the identity from cli/ui/sdk ? @yuri/@chetan
Copy link
Member

Choose a reason for hiding this comment

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

Good question, we should be consistent across all batch jobs with our use of identity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added for these two, the rest of the options do not have an identity in the proto definition. I will add that in a later PR

Comment on lines 116 to 117
ActivityOptions *activitypb.ActivityOptions
UpdateMask *fieldmaskpb.FieldMask
Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine but you should know that using a nested proto struct in workflow input doesn't use proto JSON serialization, instead it uses plain JSON serialization which may yield unexpected results.

If we were writing this from scratch, the right thing to do here is to define a proto struct for the workflow input and reuse the request structs for each of these actions.
You may want to serialize these proto messages yourself and bypass the SDK's serialization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chatted w/ Yuri on this. We already use the proto struct for FieldMask without custom serialization in other batch commands so we should be fine here.

Copy link
Member

Choose a reason for hiding this comment

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

I would test that every field in these message are properly serialized.
Generally, what we've done here is bad practice and should be avoided in our codebase. It's not just FieldMask, it's also ActivityOptions. Even if we know that all fields are properly serialized today (which I'm not convinced of), there's no guarantee that future fields will.

Copy link
Contributor

Choose a reason for hiding this comment

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

fyi: There are known issues with the default protobuf json converter when the message contains oneoff fields - https://protobuf.dev/programming-guides/json/. It's recommended to use protojson to explicitly serialize/deserialize in such cases.
In this case you're fine since UpdateActivitiesOptionsParams doesn't contain any protobufs with oneoff fields. But that may change in the future if someone adds additional fields to this input.

@spkane31 spkane31 requested a review from bergundy July 18, 2025 17:17
Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

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

I would like the input serialization issues to be addressed before merging but otherwise LGTM. Please do not merge before addressing.

Comment on lines 116 to 117
ActivityOptions *activitypb.ActivityOptions
UpdateMask *fieldmaskpb.FieldMask
Copy link
Contributor

Choose a reason for hiding this comment

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

fyi: There are known issues with the default protobuf json converter when the message contains oneoff fields - https://protobuf.dev/programming-guides/json/. It's recommended to use protojson to explicitly serialize/deserialize in such cases.
In this case you're fine since UpdateActivitiesOptionsParams doesn't contain any protobufs with oneoff fields. But that may change in the future if someone adds additional fields to this input.

@spkane31
Copy link
Contributor Author

I would like the input serialization issues to be addressed before merging but otherwise LGTM. Please do not merge before addressing.

Created structs for these options for JSON serialization purposes.

@spkane31 spkane31 enabled auto-merge (squash) July 18, 2025 21:15
@spkane31 spkane31 merged commit 0c55c45 into main Jul 18, 2025
84 of 87 checks passed
@spkane31 spkane31 deleted the spk/batch-reset-update-op branch July 18, 2025 22:38
RestoreOriginal bool
}

ActivityOptions struct {
Copy link
Member

Choose a reason for hiding this comment

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

I think this is suboptimal solution. Instead it would have been better to serialize the proto structs manually or to define the workflow inputs with protos.

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.

4 participants