Skip to content

Commit

Permalink
Handle nil valuePtr case in update handler Get (#1373)
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns committed Feb 1, 2024
1 parent 57b6679 commit 86764f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/internal_workflow_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,7 @@ func (ch *completedUpdateHandle) Get(ctx context.Context, valuePtr interface{})

func (luh *lazyUpdateHandle) Get(ctx context.Context, valuePtr interface{}) error {
enc, err := luh.client.PollWorkflowUpdate(ctx, luh.ref)
if err != nil {
if err != nil || valuePtr == nil {
return err
}
return enc.Get(valuePtr)
Expand Down
8 changes: 7 additions & 1 deletion internal/internal_workflow_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1772,6 +1772,9 @@ func TestUpdate(t *testing.T) {
err = handle.Get(context.TODO(), &got)
require.NoError(t, err)
require.Equal(t, want, got)
// Verify that calling Get with nil does not panic
err = handle.Get(context.TODO(), nil)
require.NoError(t, err)
})
t.Run("sync error", func(t *testing.T) {
svc, client := init(t)
Expand Down Expand Up @@ -1810,13 +1813,16 @@ func TestUpdate(t *testing.T) {
Outcome: mustOutcome(t, want),
},
nil,
)
).Times(2)
handle, err := client.UpdateWorkflowWithOptions(context.TODO(), req)
require.NoError(t, err)
var got string
err = handle.Get(context.TODO(), &got)
require.NoError(t, err)
require.Equal(t, want, got)
// Verify that calling Get with nil does not panic
err = handle.Get(context.TODO(), nil)
require.NoError(t, err)
})
t.Run("async error", func(t *testing.T) {
svc, client := init(t)
Expand Down

0 comments on commit 86764f8

Please sign in to comment.