mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #5647] [MERGED] fix(backend): prevent cross-user orderIndex corruption and collection deadlocks #5297
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#5297
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?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5647
Author: @shaezard
Created: 12/2/2025
Status: ✅ Merged
Merged: 1/22/2026
Merged by: @mirarifhasan
Base:
next← Head:order_index_bug_fix📝 Commits (5)
d8823a6fix: add teamID/userUid filter to updateMany queriesdce98e5fix: fix orderIndex of existing collectionsee9c626feat(backend): add cascade delete for collections880cfb8refactor(team-collection): remove manual deleteCollectionData methodd45ec2cfix(backend): fixed locking mechanisms for collections and requests📊 Changes
11 files changed (+1822 additions, -719 deletions)
View changed files
➕
packages/hoppscotch-backend/prisma/migrations/20251202154928_fix_order_index/migration.sql(+30 -0)➕
packages/hoppscotch-backend/prisma/migrations/20251203202452_cascade_delete/migration.sql(+11 -0)📝
packages/hoppscotch-backend/prisma/schema.prisma(+2 -2)📝
packages/hoppscotch-backend/src/prisma/prisma.service.ts(+37 -44)📝
packages/hoppscotch-backend/src/team-collection/team-collection.service.spec.ts(+520 -28)📝
packages/hoppscotch-backend/src/team-collection/team-collection.service.ts(+216 -229)📝
packages/hoppscotch-backend/src/team-request/team-request.service.spec.ts(+2 -2)📝
packages/hoppscotch-backend/src/team-request/team-request.service.ts(+75 -72)📝
packages/hoppscotch-backend/src/user-collection/user-collection.service.spec.ts(+616 -16)📝
packages/hoppscotch-backend/src/user-collection/user-collection.service.ts(+240 -255)📝
packages/hoppscotch-backend/src/user-request/user-request.service.ts(+73 -71)📄 Description
Closes #5646
This PR fixes a critical bug where
updateManyqueries for root collections(where
parentID: null) were missing theuserUid/teamIDfilter, potentiallycausing cross-user/cross-team data corruption.
What's changed
Added
userUidfilter touser-collection.service.ts:changeParentAndUpdateOrderIndexremoveCollectionAndUpdateSiblingsOrderIndexupdateUserCollectionOrder(both cases)getCollectionCount(now acceptsuserUidparameter)Added
teamIDfilter toteam-collection.service.ts:deleteCollectionAndUpdateSiblingsOrderIndexupdateCollectionOrder(both cases)getCollectionCount(now acceptsteamIDparameter)Added unit tests to verify the fix works correctly
Added scenario tests to verify multi-user/multi-team isolation
Notes to reviewers
specific user/team
getCollectionCountmethod signature was changed to requireuserUid/teamIDparameter - all callers have been updated accordinglySummary by cubic
Fixes missing user/team scoping in updateMany on root collections to prevent cross-user/team orderIndex corruption. Adds orderIndex normalization, cascade deletes, and scoped row locks to avoid deadlocks.
Bug Fixes
Migration
Written for commit
d45ec2cf1c. Summary will update on new commits.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.