Skip to content

GCS List method doesn't add slash suffix to prefix #21

@hirokawai

Description

@hirokawai

Same issue as #15 (Huawei OBS), but for Google Cloud Storage.

Problem

GoogleCloudStorage.List() in oss/gcsblob/gcs.go does not append a trailing slash to the prefix before listing
objects. This causes prefix collisions when multiple directories share a common prefix.

In dify-plugin-daemon, plugin/ and plugin_packages/ both exist in the same bucket. When List("plugin") is
called, GCS returns objects from both prefixes. After TrimPrefix, objects from plugin_packages/ become
_packages/... which produces invalid plugin identifiers.

ERROR dify-plugin-daemon installed_bucket.go:81 failed to create PluginUniqueIdentifier from path
path=_packages/lifull/my_plugin:0.0.1@e5bc5c2c...
error="plugin_unique_identifier is not valid"

Fix

Add the same slash suffix guard that the S3 implementation already has:

func (g *GoogleCloudStorage) List(prefix string) ([]oss.OSSPath, error) {
    if !strings.HasSuffix(prefix, "/") {
        prefix = prefix + "/"
    }
    // ... rest unchanged

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions