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 <noreply@anthropic.com>
This commit is contained in:
Daisuke Mino
2026-02-01 21:41:37 +09:00
committed by GitHub
parent b5d897642a
commit bdc2eef3cd
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -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,
})
+3
View File
@@ -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)