From bdc2eef3cdbf1241fa62dc4386b251374f4b539e Mon Sep 17 00:00:00 2001 From: Daisuke Mino Date: Sun, 1 Feb 2026 21:41:37 +0900 Subject: [PATCH] fix(gcs): List returns relative path instead of full path (#20) The GCS List method was returning full paths (attrs.Name) instead of relative paths (key with prefix stripped). This was inconsistent with other storage implementations (S3, Local, Azure, Aliyun, Tencent, Huawei, Volcengine) which all return relative paths. The original implementation in dify-plugin-daemon PR #237 correctly used `key`: https://github.com/langgenius/dify-plugin-daemon/pull/237/files#diff-1efde200d0fa3fafdd827478fdbca6e8b16dee52955cb3c93faab2849f7d95bfR136 This bug was introduced when the code was ported to dify-cloud-kit. Also added a test assertion to verify that List returns relative paths. Co-authored-by: Claude Opus 4.5 --- oss/gcsblob/gcs.go | 2 +- tests/oss/oss_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/oss/gcsblob/gcs.go b/oss/gcsblob/gcs.go index 08e7be6..0d8a531 100644 --- a/oss/gcsblob/gcs.go +++ b/oss/gcsblob/gcs.go @@ -125,7 +125,7 @@ func (g *GoogleCloudStorage) List(prefix string) ([]oss.OSSPath, error) { key = strings.TrimPrefix(key, "/") res = append(res, oss.OSSPath{ - Path: attrs.Name, + Path: key, IsDir: false, }) diff --git a/tests/oss/oss_test.go b/tests/oss/oss_test.go index f606a53..8957491 100644 --- a/tests/oss/oss_test.go +++ b/tests/oss/oss_test.go @@ -174,6 +174,9 @@ func TestAll(t *testing.T) { ossPaths, err = storage.List(prefix) assert.Equal(t, 1, len(ossPaths), info) assert.Nil(t, err, info) + // Verify that List returns relative paths (without prefix) + expectedRelativePath := key[len(prefix)+1:] // +1 for the "/" separator + assert.Equal(t, expectedRelativePath, ossPaths[0].Path, info+" - List should return relative path") err = storage.Delete(key) assert.Nil(t, err, info)