Skip to content

fix: open recipient shared-drive files from recents via the proxy#3948

Merged
rezk2ll merged 1 commit into
masterfrom
fix/shared-drive-recents-open-404
Jun 22, 2026
Merged

fix: open recipient shared-drive files from recents via the proxy#3948
rezk2ll merged 1 commit into
masterfrom
fix/shared-drive-recents-open-404

Conversation

@rezk2ll

@rezk2ll rezk2ll commented Jun 22, 2026

Copy link
Copy Markdown
Member

Problem

Opening a shared-drive file a recipient sees outside the drive view (Recents, Search) tried the local /files/:id route and 404'd, because the file lives on the owner's instance and is only reachable through the /sharings/drives proxy. computeFileType only treated a file as a shared-drive file when its parent was the shared-drives container, which never holds for a real file nested inside a drive.

Solution

Classify any file carrying a driveId as a shared-drive file (excluding the owner's own file-root sharing root, which lives locally), so it routes to /shareddrive/:driveId/:dir/file/:id. dir_id is now required for that classification so a doc missing it falls back to the local route instead of throwing, and the folder-path prefix used by Favorites no longer mangles the already-absolute shared-drive path. Adds an e2e test covering a recipient opening a shared-drive file through the proxy.

Summary by CodeRabbit

  • Bug Fixes

    • Improved shared-drive file routing and loading for recipient accounts
    • Fixed path resolution for shared-drive files nested in folders
  • Tests

    • Added end-to-end test validating shared-drive file opening for recipients
    • Enhanced test coverage for shared-drive file type computation and path resolution

A file carrying a driveId is a proxied shared-drive file, but computeFileType
only classified it as such when dir_id was the shared-drives container, which
is never true for a real file nested in a drive. Those files fell through to
the local /files/:id route and 404'd for the recipient. Key on driveId (minus
the owner's own file-root root) and require dir_id so the route can be built.
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The PR fixes routing for shared-drive recipient files nested inside folders. In computeFileType (helpers.ts), the condition for classifying a file as shared-drive-file is changed from checking dir_id === SHARED_DRIVES_DIR_ID to checking dir_id is present and !isFileRootSharedDrive(file), which correctly handles files nested in sub-folders. In useFileLink.tsx, a guard is added so that the forceFolderPath prefix is skipped when the resolved path already starts with /. Unit tests in helpers.spec.js are updated to cover these cases, and a new Playwright e2e spec validates the full recipient shared-drive file open flow.

Suggested labels

e2e

Suggested reviewers

  • doubleface
  • zatteo
  • lethemanh
  • JF-Cozy
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: open recipient shared-drive files from recents via the proxy' directly and specifically describes the main change: enabling recipients to open shared-drive files through the proxy instead of incorrectly routing to local endpoints.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/shared-drive-recents-open-404

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our agent can fix these. Install it.

Gates Passed
3 Quality Gates Passed

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@bundlemon

bundlemon Bot commented Jun 22, 2026

Copy link
Copy Markdown

BundleMon

Unchanged files (20)
Status Path Size Limits
static/js/cozy.(hash).js
928.36KB -
static/resource/(hash).js
336.09KB -
services/qualificationMigration.js
283.39KB -
services/dacc.js
263.13KB -
static/js/main.(hash).js
48.83KB -
static/js/lib-react.(hash).js
43.88KB -
static/css/cozy.(hash).css
30.13KB -
static/js/lib-polyfill.(hash).js
22.77KB -
static/js/lib-router.(hash).js
21.86KB -
static/js/public.(hash).js
19.77KB -
static/css/main.(hash).css
13.57KB -
static/js/intents.(hash).js
8.99KB -
static/js/(chunkId).(hash).js
8.6KB -
static/js/async/(chunkId).(hash).js
7.5KB -
manifest.webapp
3.09KB -
static/css/public.(hash).css
2.34KB -
index.html
772B -
public/index.html
705B -
intents/index.html
642B -
assets/manifest.json
185B -

Total files change +1B 0%

Groups updated (1)
Status Path Size Limits
**/*.js
5.98MB (+15B 0%) -
Unchanged groups (2)
Status Path Size Limits
**/*.{png,svg,ico}
2.16MB -
**/*.css
77.43KB -

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/tests/z-shared-drive-open-file.spec.ts`:
- Around line 65-67: The network assertion in the bobPage.waitForResponse call
only validates the URL pattern but does not verify the HTTP method, allowing
non-POST requests to the same path to satisfy the wait condition and potentially
mask regressions. Update the response matcher to additionally check that the
request method is POST by examining the request object alongside the URL
pattern, ensuring both conditions are met before the wait resolves.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aaa9835e-4f02-4708-ac49-b863b9854179

📥 Commits

Reviewing files that changed from the base of the PR and between c77457e and 402b9db.

📒 Files selected for processing (4)
  • e2e/tests/z-shared-drive-open-file.spec.ts
  • src/modules/navigation/hooks/helpers.spec.js
  • src/modules/navigation/hooks/helpers.ts
  • src/modules/navigation/hooks/useFileLink.tsx

Comment on lines +65 to +67
bobPage.waitForResponse(
res => /\/sharings\/drives\/[^/]+\/downloads/.test(res.url()),
{ timeout: 20_000 }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Tighten the network assertion to the expected POST download call.

The response matcher is URL-only right now, so a non-POST hit to the same path could satisfy the wait and mask a regression.

Suggested patch
-    const [proxiedDownload] = await Promise.all([
-      bobPage.waitForResponse(
-        res => /\/sharings\/drives\/[^/]+\/downloads/.test(res.url()),
-        { timeout: 20_000 }
-      ),
+    const [proxiedDownload] = await Promise.all([
+      bobPage.waitForResponse(
+        res =>
+          res.request().method() === 'POST' &&
+          /\/sharings\/drives\/[^/]+\/downloads$/.test(
+            new URL(res.url()).pathname
+          ),
+        { timeout: 20_000 }
+      ),
       bobDrive.row(FILE_NAME).open()
     ])
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
bobPage.waitForResponse(
res => /\/sharings\/drives\/[^/]+\/downloads/.test(res.url()),
{ timeout: 20_000 }
bobPage.waitForResponse(
res =>
res.request().method() === 'POST' &&
/\/sharings\/drives\/[^/]+\/downloads$/.test(
new URL(res.url()).pathname
),
{ timeout: 20_000 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/tests/z-shared-drive-open-file.spec.ts` around lines 65 - 67, The network
assertion in the bobPage.waitForResponse call only validates the URL pattern but
does not verify the HTTP method, allowing non-POST requests to the same path to
satisfy the wait condition and potentially mask regressions. Update the response
matcher to additionally check that the request method is POST by examining the
request object alongside the URL pattern, ensuring both conditions are met
before the wait resolves.

@rezk2ll rezk2ll merged commit 25697e1 into master Jun 22, 2026
6 checks passed
@rezk2ll rezk2ll deleted the fix/shared-drive-recents-open-404 branch June 22, 2026 13:51
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.

3 participants