mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[GH-ISSUE #5646] [bug]: Cross-user/Cross-team orderIndex corruption due to missing teamID/userUid filter in updateMany queries #2186
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#2186
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @shaezard on GitHub (Dec 2, 2025).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/5646
Originally assigned to: @shaezard on GitHub.
Is there an existing issue for this?
Platform
Web App
Browser
Chrome
Operating System
macOS
Bug Description
What happened?
In both
user-collection.service.tsandteam-collection.service.ts, severalupdateManyqueriesfor root collections (where
parentID: null) are missing theuserUid/teamIDfilter. This meansoperations like deleting or reordering root collections can affect ALL users'/teams' root collections
in the database, not just the current user's/team's.
Affected Files and Lines
user-collection.service.ts
changeParentAndUpdateOrderIndex(lines 487-493)removeCollectionAndUpdateSiblingsOrderIndex(lines 568-574)updateUserCollectionOrder- null case (lines 746-752)updateUserCollectionOrder- with nextCollectionID (lines 829-837)getCollectionCount(lines 698-702)team-collection.service.ts
deleteCollectionAndUpdateSiblingsOrderIndex(lines 565-571)updateCollectionOrder- to end (lines 894-904)updateCollectionOrder- with nextCollectionID (lines 975-983)getCollectionCount(lines 851-854)Example of the Bug
When User A deletes their root collection with
orderIndex: 2, the following query runs:await tx.userCollection.updateMany({
where: {
parentID: null, // Matches ALL users' root collections!
orderIndex: { gt: 2 },
},
data: { orderIndex: { decrement: 1 } },
});This decrements
orderIndexfor ALL users' root collections withorderIndex > 2,corrupting other users' collection ordering.
Expected Behavior
The query should include
userUidfilter:await tx.userCollection.updateMany({
where: {
userUid: collection.userUid, // <-- This is missing!
parentID: null,
orderIndex: { gt: 2 },
},
data: { orderIndex: { decrement: 1 } },
});## Impact
Proposed Fix
Add the
userUid/teamIDfilter to all affectedupdateManyandcountqueries.I have already implemented and tested the fix locally.
Deployment Type
Hoppscotch Cloud
Version
No response
@jamesgeorge007 commented on GitHub (Jan 28, 2026):
Closing since this is now addressed in the v2026.1.0 release.