fix: range copy, DM member assignment, SQLite variable limit#665
Open
Fizmatik wants to merge 1 commit intorusq:masterfrom
Open
fix: range copy, DM member assignment, SQLite variable limit#665Fizmatik wants to merge 1 commit intorusq:masterfrom
Fizmatik wants to merge 1 commit intorusq:masterfrom
Conversation
Three bugs found during a real Slack-to-Mattermost migration (31 users, 5M posts, 76K files): 1. source.go: Channels() uses range-value loop, so assigning Members to the loop variable modifies a copy — the original slice element is never updated. All channels end up with empty Members. Fix: use index-based iteration. 2. index.go: convertToDM case 1 uses `me` (the current workspace user) instead of the actual channel member. This makes every single-member DM appear as a conversation with the archiving user. Fix: use ch.Members[0] instead of me. 3. dedupe.go: deleteChunksByID passes all chunk IDs (147K+ in large workspaces) as bind parameters in a single DELETE query, exceeding SQLite's SQLITE_MAX_VARIABLE_NUMBER limit. Fix: batch deletes in groups of 10,000.
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
Three bugs found during a real Slack-to-Mattermost migration (31 users, 5M posts, 76K files):
source.go: range-value copy bug —
Channels()iterates withfor _, c := range chns, soc.Members = usersassigns to a copy of the struct. The original slice element is never updated, leaving all channels with empty Members. Fixed with index-based iteration.index.go: wrong DM member —
convertToDMcase 1 (single-member DMs) usesme(the archiving user) instead ofch.Members[0]. This makes every single-member DM appear as a conversation with the current user, rather than the actual participant. Fixed by using the actual member.dedupe.go: SQLite variable limit —
deleteChunksByIDpasses all chunk IDs (147K+ in large workspaces) as bind parameters in a singleDELETE ... WHERE ID IN (?)query, exceeding SQLite'sSQLITE_MAX_VARIABLE_NUMBER. Fixed with batched deletes (10,000 IDs per query).Test plan
ch.Members[0] != mego test ./internal/structures/ ./internal/chunk/backend/dbase/ ./internal/chunk/backend/dbase/repository/— all pass