mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2697] [Issue]: Full backup omits the encryption key (restored API keys become empty) and custom emoji/sticker images #1342
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1342
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 @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2697
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The full backup/restore drops two categories of critical files, so a restored backup is silently lossy: (1) it omits
DATA_DIR/.encryption-key, so on restore every stored API key becomes undecryptable (blank); (2) it omits thecustom-emojisandcustom-stickersimage directories, so every custom emoji/sticker renders broken after restore even though their DB rows are restored.Expected behavior
A full (same-user) backup should restore to a working state — all connections keep their API keys, and all custom emoji/sticker images render.
Actual behavior
BACKUP_DIRSsubdir (includingstorage, which holdsapiKeyEncryptedciphertext) — but never copyDATA_DIR/.encryption-key. On restore to a new machine/wiped data dir, a fresh.encryption-keyis auto-generated, sodecryptApiKeyfails the GCM auth-tag check for every connection and returns"". All keys are silently lost even though the ciphertext was faithfully restored.BACKUP_DIRS/PROFILE_ASSET_DIRSlist storage/avatars/sprites/backgrounds/gallery/fonts/knowledge-sources/game-assets/lorebooks-images/agents-images/connections-images — but notcustom-emojisorcustom-stickers. Thecustom_emojis/custom_stickersrows export in the storage snapshot, but their image files (underDATA_DIR/custom-emojis/andcustom-stickers/) are never collected, andnormalizeProfileAssetPathwould reject them even if hand-added. On restore the rows point at files that were never backed up → every:emoji:/sticker:token 404s.How it breaks the pipeline
Code trace (staging @
b826f8f4):packages/server/src/routes/backup.routes.ts— folder backup (POST/, ~:1631-1658) and download backup (POST/download, ~:1681-1719) copyBACKUP_DIRS(:34-46) but not.encryption-key. Key read/auto-gen atpackages/server/src/utils/crypto.ts:34-46; decrypt-fail returns""atcrypto.ts:78-82.BACKUP_DIRS/PROFILE_ASSET_DIRS(backup.routes.ts:34-47) omitcustom-emojis/custom-stickers;collectProfileAssetFiles(:488-524) and the cp loops (:1653-1658,:1702-1719) only walk those dirs;normalizeProfileAssetPath(~:419-431) allowlists onlyPROFILE_ASSET_DIRS. Image files live atcustom-emojis.routes.ts:17/custom-stickers.routes.ts:21.Steps to reproduce
POST /api/backup/download→ extract the zip onto a fresh data dir → start the app → a new.encryption-keyis generated → the key is blank, chat fails with auth errors.DATA_DIR/custom-emojis/<file>+ a row) → Profile Export /POST /api/backup/download→ restore into a clean install → the row exists but the image 404s.Suggested fix
.encryption-keyin the full folder + download backups (explicitly copy/add it), with a clear warning inRESTORE.txtthat the archive contains secret-key material. Do not add it to the redacting profile export meant for sharing; or document thatENCRYPTION_KEYmust be exported separately.custom-emojisandcustom-stickerstoBACKUP_DIRS(soPROFILE_ASSET_DIRSderives them andnormalizeProfileAssetPathaccepts them); verify the round-trip restores image files alongside rows.Environment
b826f8f4)Additional context
Found via a systematic multi-agent audit of import/export round-trips for 2.0.0. (1) makes a same-user backup non-restorable for connections; (2) is silent image loss. Part of a set of import/export fidelity issues filed together.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in branch
codex/spicy-issue-sweep-2026-06-21.What changed:
.encryption-keywhen the persisted key file exists..encryption-keywhen present.ENCRYPTION_KEYmust be restored separately.custom-emojisandcustom-stickersto the backup/profile asset allowlist so their image files round-trip with their storage rows.Final repo checks will run after the full issue sweep.