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

Fix kotlin child workflow execute varargs #2395

Conversation

adamlehenbauer
Copy link
Contributor

@adamlehenbauer adamlehenbauer commented Jan 30, 2025

What was changed

The kotlin execute extension functions on child workflows aren't working for me. My args are wrapped in an array, causing my child workflow to fail when deserializing it's workflow arguments.

I'm no expert on kotlin/java varargs, but it seems to me that the varargs need to be spread so that the java code sees varargs, not a one element array of varargs.

I've added test cases that fail in the way that I'm seeing if the spread operator is dropped, and ensure correct functioning going forward.

Related issues: #2018

Why?

I'm using untyped child workflows myself, and passing my arguments through is leading to workflow failures.

Checklist

  1. Closes n/a

  2. How was this tested:

  • The unit tests provided exercise this fix and demonstrate the bug without the fix
  • I've tested in a real application with a copy/pasted execute function that includes the spread, and this works as expected
  1. Any docs updates needed?

n/a

@adamlehenbauer adamlehenbauer requested a review from a team as a code owner January 30, 2025 14:04
@CLAassistant
Copy link

CLAassistant commented Jan 30, 2025

CLA assistant check
All committers have signed the CLA.

@@ -28,13 +28,13 @@ import kotlin.reflect.typeOf
*/
@OptIn(ExperimentalStdlibApi::class)
inline fun <reified T> ChildWorkflowStub.execute(vararg args: Any?): T {
return execute(T::class.java, typeOf<T>().javaType, args)
return execute(T::class.java, typeOf<T>().javaType, *args)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If not spread here, the args are considered a single argument to the java execute function.

So if passing in a single string arg like "my-arg", the child workflow will receive [ "my-arg" ] as it's first argument, rather than "my-arg"

@Quinn-With-Two-Ns
Copy link
Contributor

Hey, thanks for the contribution. I think Activities also have the same issue, are you able to resolve that as part of this PR as well?

@adamlehenbauer adamlehenbauer force-pushed the fix/child-workflow-execute-varargs branch from a57a47d to a7b8bd2 Compare February 1, 2025 19:00
@adamlehenbauer adamlehenbauer force-pushed the fix/child-workflow-execute-varargs branch from a7b8bd2 to f877a63 Compare February 1, 2025 19:04
@adamlehenbauer
Copy link
Contributor Author

Hey, thanks for the contribution. I think Activities also have the same issue, are you able to resolve that as part of this PR as well?

Updated to include the activity executes

@adamlehenbauer
Copy link
Contributor Author

@Quinn-With-Two-Ns anything I need to do here?

@Quinn-With-Two-Ns
Copy link
Contributor

Looks like CI is failing, can you please make sure tags are pushed to your branch? don't think I can push them for you. Then let me know and I will re-run CI. Thanks!

@adamlehenbauer
Copy link
Contributor Author

@Quinn-With-Two-Ns which tags? I haven't created any new ones. Pushing all failed for me (! [remote rejected] v0.29.0 -> v0.29.0 (refusing to allow an OAuth App to create or update workflow.github/workflows/gradle-wrapper-validation.ymlwithoutworkflow scope).

I've synced the fork now, not sure if that helps

@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit 32fbf02 into temporalio:master Feb 10, 2025
8 checks passed
@adamlehenbauer adamlehenbauer deleted the fix/child-workflow-execute-varargs branch February 18, 2025 17:04
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