fix: correct userId corruption when moving shared content to a folder (#2670)#2926
Open
cqnykamp wants to merge 1 commit into
Open
fix: correct userId corruption when moving shared content to a folder (#2670)#2926cqnykamp wants to merge 1 commit into
cqnykamp wants to merge 1 commit into
Conversation
…content to a folder
The for...of loop `for (userId of sourceSharedWith)` was mutating the
`userId` function parameter instead of using a new loop variable. When
moving content that was shared with other users, this caused `userId` to
be overwritten with the last shared user's ID. The resulting destination
URL `/activities/${userId}/${folderId}` would point to the wrong user,
causing a 404 error when clicking "Go to folder" after the move.
Also fixes the related sharedWith type mismatch:
- `getMoveCopyContentData` now returns `sharedWith: {userId: string}[]`
instead of the full contentShares relation (which includes extra fields
not needed here)
- `ActiveView.parent.sharedWith` type updated from `string[]` to
`{userId: string}[]` to match the actual API response
- The shareAlert comparison now correctly uses `share.userId` instead of
comparing the raw share object against a string map key
Adds E2E test for moving a document to a folder and clicking "Go to folder"
(previously untested), and a component test verifying the destination URL
uses the correct userId when content and destination have shared users.
Closes #2670
https://claude.ai/code/session_015zUyV9xisamvNrjBnCbQC3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2670 — "Moving document to another folder and then clicking Open Folder causes error"
Root Cause
In
MoveCopyContent.tsx, theshareAlertcomputation contained afor...ofloop that used the component'suserIdprop as the loop variable (without declaring a newconst/letvariable):When moving content that was explicitly shared with other users, this loop overwrote the
userIdparameter with the last shared-user's ID. The destination URL was then computed as:Navigating to
/activities/{wrongUserId}/{folderId}caused the API to either return{notMe: true}(redirecting to Shared Activities) or a 404 if the folder wasn't publicly accessible — showing the error page.A secondary bug: the
ActiveView.parent.sharedWithTypeScript type was declared asstring[], butgetMoveCopyContentDatareturned the fullcontentSharesrelation (array of objects). This meant theshareAlertcheckcount.get(user)was comparing a string map key against a whole object, always returningundefinedand incorrectly triggering share alerts for any shared destination folder.Changes
apps/app/src/popups/MoveCopyContent.tsxfor (userId of sourceSharedWith)→for (const sharedUserId of sourceSharedWith)to stop corrupting theuserIdpropActiveView.parent.sharedWithtype fromstring[]to{ userId: string }[]shareAlertcomparison to useshare.userIdinstead of the raw objectapps/api/src/query/copy_move.tsgetMoveCopyContentData, narrowsharedWith: truetosharedWith: { select: { userId: true } }so the response only includes theuserIdfield, matching the updated frontend typepackages/e2e-tests/e2e/Content Lists/move.cy.tsapps/app/src/popups/MoveCopyContent.cy.tsxuserIdprop is not corrupted by the loop when shared content is moved to a shared-with folderTest plan
npm run format && npm run lintcleanhttps://claude.ai/code/session_015zUyV9xisamvNrjBnCbQC3
Generated by Claude Code