Skip to content

fix(plugin-cloud-storage): dedupe client upload filenames within the prefix when filename is unique per prefix - #19247

Open
lazerg wants to merge 2 commits into
payloadcms:mainfrom
lazerg:fix/issue-19246-signed-url-prefix-dedupe
Open

lazerg wants to merge 2 commits into
payloadcms:mainfrom
lazerg:fix/issue-19246-signed-url-prefix-dedupe

Conversation

@lazerg

@lazerg lazerg commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

What?

With upload.filenameCompoundIndex containing prefix, the client upload signing step now checks for a duplicate filename only inside the signed prefix.

Why?

resolveSignedURLKey called getSafeFileName without a prefix, so the lookup ran across the whole collection. Uploading logo.png into prefix B was renamed to logo-1.png because prefix A already had a logo.png, even though the compound index allows the same name in different prefixes. Server uploads already pass the prefix in generateFileData.

How?

The prefix is resolved before the duplicate check and passed to getSafeFileName when the collection's filename is unique per prefix. Without the compound index the unique index on filename stays global, so the lookup stays global too. Added a unit spec.

Fixes #19246

3.x backport: #19248

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between c9ad852 and b460c36.

Files selected for processing: 1
  • packages/plugin-cloud-storage/src/utilities/resolveSignedURLKey.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Walkthrough

Client-upload signing now scopes filename collision checks to the resolved prefix when filenameCompoundIndex includes prefix. Otherwise, collision checks remain unscoped. Tests cover both cases and reuse a shared request object.

Changes: Client-upload filename scope

Layer / File(s) Summary
Resolve prefix and check filename collisions
packages/plugin-cloud-storage/src/utilities/resolveSignedURLKey.ts, packages/plugin-cloud-storage/src/utilities/resolveSignedURLKey.spec.ts
resolveSignedURLKey resolves the sanitized document prefix before checking filename collisions. It passes the prefix to getSafeFileName when filenameCompoundIndex includes prefix. Tests cover prefixed and unscoped checks and use a shared request object in existing cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: nathanlentz, jessrynkar

Merge Risk: Minimal · up to b460c

The client upload lookup follows the configured filename uniqueness mode, with no merge-blocking risk identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the affected plugin and the core change: client upload filename deduplication is scoped to the prefix when the compound index includes prefix. It matches the raw summary and objectives…
Description check Passed The description states the change, the cause, the approach, and the test coverage. It links the issue (#19246) and a backport. It directly describes the changed behavior in resolveSignedURLKey, so it …
Linked Issues check Passed Issue #19246 requires prefix-scoped collision checks for client-upload signing when filenameCompoundIndex includes prefix. resolveSignedURLKey now resolves sanitizedDocPrefix before the collis…
Out of Scope Changes check Passed The changes are limited to the linked issue. The implementation updates prefix selection for filename collision checks. The tests verify prefix-scoped and global lookup behavior. No unrelated product …
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Title check

Explanation

The title names the affected plugin and the core change: client upload filename deduplication is scoped to the prefix when the compound index includes prefix. It matches the raw summary and objectives. The title is long (110 characters) but still specific and accurate.

Full details: Description check

Explanation

The description states the change, the cause, the approach, and the test coverage. It links the issue (#19246) and a backport. It directly describes the changed behavior in resolveSignedURLKey, so it is on topic.

Full details: Linked Issues check

Explanation

Issue #19246 requires prefix-scoped collision checks for client-upload signing when filenameCompoundIndex includes prefix. resolveSignedURLKey now resolves sanitizedDocPrefix before the collision check and passes it to getSafeFileName in that case. It passes undefined otherwise, which preserves global filename checks. The unit specs cover both configurations.

Full details: Out of Scope Changes check

Explanation

The changes are limited to the linked issue. The implementation updates prefix selection for filename collision checks. The tests verify prefix-scoped and global lookup behavior. No unrelated product behavior is present in the reviewed diff.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugin-cloud-storage: clientUploads renames a file for a name held in another prefix, ignoring filenameCompoundIndex

1 participant