From 7fdd2e7880ab6739d261a100790df45635cefb42 Mon Sep 17 00:00:00 2001 From: Snarr Date: Thu, 19 Dec 2024 11:06:15 -0500 Subject: [PATCH] Allow passed content to be of type LHVariableValue --- sdk-go/littlehorse/lh_variables.go | 5 +++++ sdk-go/littlehorse/task_worker_internal.go | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sdk-go/littlehorse/lh_variables.go b/sdk-go/littlehorse/lh_variables.go index 040b966f2..432f12b9f 100644 --- a/sdk-go/littlehorse/lh_variables.go +++ b/sdk-go/littlehorse/lh_variables.go @@ -146,6 +146,11 @@ func InterfaceToVarVal(someInterface interface{}) (*lhproto.VariableValue, error out := &lhproto.VariableValue{} var err error + interfaceAsVarVal, isVarVal := someInterface.(*lhproto.VariableValue) + if isVarVal { + return interfaceAsVarVal, nil + } + isPtr, _ := GetIsPtrAndType(reflect.TypeOf(someInterface)) if someInterface == nil { return &lhproto.VariableValue{}, nil diff --git a/sdk-go/littlehorse/task_worker_internal.go b/sdk-go/littlehorse/task_worker_internal.go index 743de7edb..bfd0988d5 100644 --- a/sdk-go/littlehorse/task_worker_internal.go +++ b/sdk-go/littlehorse/task_worker_internal.go @@ -431,12 +431,12 @@ func (m *serverConnectionManager) doTaskHelper(task *lhproto.ScheduledTask) *lhp if errorReflect.Interface() != nil { // Check if the error is an LHTaskException if lhtErr, ok := errorReflect.Interface().(*LHTaskException); ok { - taskErrVarVal, err := InterfaceToVarVal(lhtErr.Content) + taskErrContent, err := InterfaceToVarVal(lhtErr.Content) if err != nil { - msg := "Failed to serialize task error content: " + err.Error() + msg := "LH_SDK_GO_ERR: Failed to serialize task error content passed from task worker: " + err.Error() - taskErrVarVal = &lhproto.VariableValue{ + taskErrContent = &lhproto.VariableValue{ Value: &lhproto.VariableValue_Str{ Str: msg, }, @@ -447,7 +447,7 @@ func (m *serverConnectionManager) doTaskHelper(task *lhproto.ScheduledTask) *lhp Exception: &lhproto.LHTaskException{ Name: lhtErr.Name, Message: lhtErr.Message, - Content: taskErrVarVal, + Content: taskErrContent, }, } } else {