From db4812fbfa5e4689fac790333cbbee115d1f9de2 Mon Sep 17 00:00:00 2001 From: n4n5 <56606507+Its-Just-Nans@users.noreply.github.com> Date: Fri, 25 Jul 2025 16:37:25 +0200 Subject: [PATCH] rc: listremotes should send an empty array instead of nil --- fs/config/rc.go | 3 +++ fs/config/rc_test.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/fs/config/rc.go b/fs/config/rc.go index 07f309e76..c87dcb318 100644 --- a/fs/config/rc.go +++ b/fs/config/rc.go @@ -106,6 +106,9 @@ See the [listremotes](/commands/rclone_listremotes/) command for more informatio // including any defined by environment variables. func rcListRemotes(ctx context.Context, in rc.Params) (out rc.Params, err error) { remoteNames := GetRemoteNames() + if remoteNames == nil { + remoteNames = []string{} + } out = rc.Params{ "remotes": remoteNames, } diff --git a/fs/config/rc_test.go b/fs/config/rc_test.go index 68c127a03..b21b8af50 100644 --- a/fs/config/rc_test.go +++ b/fs/config/rc_test.go @@ -138,6 +138,22 @@ func TestRc(t *testing.T) { assert.Nil(t, out) assert.Equal(t, "", config.GetValue(testName, "type")) assert.Equal(t, "", config.GetValue(testName, "test_key")) + + t.Run("ListRemotes empty not nil", func(t *testing.T) { + call := rc.Calls.Get("config/listremotes") + assert.NotNil(t, call) + in := rc.Params{} + out, err := call.Fn(context.Background(), in) + require.NoError(t, err) + require.NotNil(t, out) + + var remotes []string + err = out.GetStruct("remotes", &remotes) + require.NoError(t, err) + + assert.NotNil(t, remotes) + assert.Empty(t, remotes) + }) } func TestRcProviders(t *testing.T) {