Skip to content

Filename unique error for media when using multi-tenant-plugin #15151

@tapartdev

Description

@tapartdev

Describe the Bug

When using the multi-tenant-plugin, uploading a media file with a filename that already exists under a different tenant triggers a validation error. The error occurs even though the filename is unique within the current tenant.

Expected behavior:

The media file should upload successfully since the filename is unique within the context of Tenant B.

Actual behavior:

A validation error is returned:

{
    "errors": [
        {
            "name": "ValidationError",
            "data": {
                "errors": [
                    {
                        "message": "Value must be unique",
                        "path": "filename"
                    }
                ]
            },
            "message": "The following field is invalid: filename"
        }
    ]
}

Notes:

The error seems to enforce global uniqueness rather than tenant-scoped uniqueness.

This issue prevents uploading files with the same name across different tenants.

Link to the code that reproduces this issue

Reproduction Steps

Set up multiple tenants using the multi-tenant-plugin.

Upload a media file (e.g., image.jpg) under Tenant A.

Switch to Tenant B and try to upload a media file with the same filename (image.jpg).

Which area(s) are affected?

plugin: multi-tenant

Environment Info

Payload version: 3.69.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions