From 37ed7e21d62308c46eede4a79d64b015f50fc183 Mon Sep 17 00:00:00 2001 From: minodisk Date: Thu, 29 Jan 2026 16:06:27 +0900 Subject: [PATCH] fix(gcs): List returns relative path instead of full path 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 43a8eb4..40fdfc5 100644 --- a/oss/gcsblob/gcs.go +++ b/oss/gcsblob/gcs.go @@ -116,7 +116,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)