phanikumv commented on code in PR #75443:
URL: https://github.com/apache/airflow/pull/75443#discussion_r4358677045


##########
go-sdk/internal/bundle/task.go:
##########
@@ -183,28 +183,28 @@ func (f *taskFunction) call(
                        )
                }
        }
+       if err != nil {
+               return err
+       }
        if branch != nil {
-               // The task pushes the value that decide returns, and decide 
runs only on a result that fn
-               // returned without an error. So the task pushes no XCom when 
fn or decide fails.
-               if err != nil {
-                       return err
-               }
+               // The task pushes the value that decide returns.
                value, skipped, err := f.decide(retValues[0].Interface())
                if err != nil {
                        return err
                }
                rv := reflect.ValueOf(value)
                if rv.Kind() != reflect.Ptr || !rv.IsNil() {
-                       f.sendXcom(ctx, value, sdkClient, logger)
+                       if err := pushReturnValue(ctx, value, sdkClient); err 
!= nil {
+                               return err
+                       }
                }
                return branch.skipDownstream(ctx, sdkClient, skipped, logger)
        }
        // If there are two results, convert the first only if it's not a nil 
pointer
        if len(retValues) > 1 && (retValues[0].Kind() != reflect.Ptr || 
!retValues[0].IsNil()) {
-               res := retValues[0].Interface()
-               f.sendXcom(ctx, res, sdkClient, logger)
+               return pushReturnValue(ctx, retValues[0].Interface(), sdkClient)

Review Comment:
   The nil-pointer check here predates this PR, but nothing tests it on the 
plain-task path; TestBranchFunctionPushesNoNilPointer only covers the branch 
path. Now that a push can fail the task, a nil pointer that slipped past this 
check would be
   pushed as null, so a small test would be useful. 
   
   The check itself doesn't need to change, so this is test code to add to 
task_test.go, not a suggestion on this line:
   
     ```go
     func (s *TaskSuite) TestPushesNoNilPointer() {
             task, err := NewTaskFunction(func(contexttest.Context) (*int, 
error) { return nil, nil })
             s.Require().NoError(err)
   
             client := &recordingClient{}
             s.Require().NoError(runTask(task, client, true, false))
   
             s.Empty(client.calls)
     }
     ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to