Skip to content

Conversation

LukaGiorgadze
Copy link

closes #2049

What was changed

  • Updated getFunctionName of ExecuteActivity to check if the provided value implements fmt.Stringer.
  • If so, it now returns the result of String() directly instead of inspecting the function pointer.
  • Existing behavior for raw strings and function pointers remains unchanged.

Why?

  • Allows custom types like ActivityName to define their activity names using String().
  • Prevents incorrect behavior or panics when passing values that are Stringer but not functions.

Example

type ActivityName string

func (a ActivityName) String() string {
	return string(a)
}

var agentPlannerActivity ActivityName = "AgentPlannerActivity"

fut := workflow.ExecuteActivity(ctx, agentPlannerActivity, inputs{})

Without that, we are encountering an error, and it is difficult to comprehend the underlying reason:

3:22PM INF log/with_logger.go:45 Task processing failed with error Namespace=default TaskQueue=chat-agent [email protected]@ WorkerType=WorkflowWorker Error="BadScheduleActivityAttributes: ActivityType is not set on ScheduleActivityTaskCommand. ActivityID=15"

Checklist

  1. Closes

  2. How was this tested:

  • Added/ran unit tests to cover:
    • Stringer types (e.g. ActivityName)
    • Plain strings
  1. Any docs updates needed?
  • No public API change.
  • No docs updates required unless internal developer guide references getFunctionName.

@LukaGiorgadze LukaGiorgadze requested a review from a team as a code owner September 11, 2025 12:03
@CLAassistant
Copy link

CLAassistant commented Sep 11, 2025

CLA assistant check
All committers have signed the CLA.

}

func getFunctionName(i interface{}) (name string, isMethod bool) {
if s, ok := i.(fmt.Stringer); ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

if we do decided to accept this change, I think we would have to check for fmt.Stringer after the function pointer check due to non determinism concerns.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you, updated!

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.

Support fmt.Stringer in ExecuteActivity

3 participants