LibreChat/config
Danny Avila 2d606a9783
🧹 chore: Migrate Legacy Duplicate Code Files Blocking Dedupe Index (#14593)
Atomic file claiming (#11675) added a unique partial index on
(filename, conversationId, context, tenantId) for execute_code outputs.
Records written before it inserted a new document per regeneration, so
any deployment that re-ran a cell producing the same filename carries
duplicates the index cannot span: Mongo aborts the build with E11000 and
the constraint is silently absent — the claim path still works, but
without its database-level guard against concurrent inserts.

Adds config/migrate-code-file-duplicates.js to normalize that legacy
data, following the existing migration conventions (dry-run default,
--batch-size, runAsSystem for cross-tenant scans).

Renames rather than deletes: each duplicate is a distinct stored object,
typically still referenced by a message attachment, so removing one
would strip a real artifact from a user's history. The newest record
keeps the canonical name — matching the claim path's latest-write-wins
behavior — and older copies gain a ' (n)' suffix that skips names
already taken in the conversation. Attachments embed their own filename,
so rendered history is unchanged.

After a successful apply the script builds the index directly (targeted
createIndex, not syncIndexes) so the operator learns immediately whether
the constraint is now in place.
2026-08-02 06:41:21 -04:00
..
__tests__
translations
add-balance.js
ban-user.js
circular-deps.mjs
connect.js
create-user.js
delete-banner.js
delete-user.js
deployed-update.js
flush-cache.js
helpers.js
invite-user.js
jest.config.js
list-balances.js
list-users.js
migrate-agent-permissions.js
migrate-code-file-duplicates.js
migrate-orphaned-agent-files.js
migrate-prompt-permissions.js
migrate-shared-link-permissions.js
migrate-terms-timestamp.js
packages.js
prepare.js
reset-meili-sync.js
reset-password.js
reset-terms.js
set-balance.js
smart-reinstall.js
stop-backend.js
test-subdirectory-setup.sh
update-banner.js
update.js
user-stats.js