[PR #887] [MERGED] Fix profile import completeness #4823

Closed
opened 2026-10-22 04:10:57 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/887
Author: @cha1latte
Created: 5/15/2026
Status: ✅ Merged
Merged: 5/15/2026
Merged by: @cha1latte

Base: staging ← Head: fix/issue-847-profile-import-completeness


📝 Commits (1)

  • 8dcd7cc Fix profile import completeness

📊 Changes

2 files changed (+402 additions, -2 deletions)

View changed files

📝 packages/server/src/routes/backup.routes.ts (+185 -2)
➕ packages/server/test/profile-backup-routes.test.ts (+217 -0)

📄 Description

Linked issue

Closes #847

Why this change

  • Profile export/import could silently round-trip only a subset of a user's data. Chats, messages, connections, gallery image rows, and other file-native tables were not included in the profile envelope, and semantic lorebook import could leave links pointing at old character IDs.

What changed

  • Adds a fileStorage snapshot to native profile exports so file-native tables round-trip with stable IDs.
  • Restores exported profile asset files from avatars, sprites, backgrounds, gallery, fonts, and knowledge-sources during profile import.
  • Keeps the existing semantic profile importer as the fallback for older exported profile JSON files.
  • Redacts API connection keys and agent secret-like settings in profile snapshots; connection definitions restore, but API keys still need to be re-entered after import.
  • Adds a server regression test covering chats, messages, connections, lorebook character links, avatar/gallery files, and API key redaction.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Codex reproduced the bug before the fix with pnpm --dir packages/server exec tsx ../../scratch/issue-847-profile-roundtrip-repro.ts: the exported profile lacked a file-native table snapshot, and import restored 0 chats, 0 messages, 0 connections, 0 chat image rows, 0 character image rows, and no gallery files.
  • Codex re-ran the same scratch repro after the fix. It now exports fileStorage and restores 1 chat, 1 message, 1 connection, 1 lorebook character link, 1 chat image row, 1 character image row, the avatar file, and both gallery files. Output saved locally at scratch/issue-847-after-output.txt.
  • Codex ran pnpm --dir packages/server exec tsx --test test/profile-backup-routes.test.ts; it passed.
  • Codex ran pnpm check; it passed.
  • True human/manual limitation: the reporter's real 82.9 MB Google Drive profile was not imported on this machine. The synthetic repro exercises the same profile export/import route and affected data classes.
  • Security note: API key secrets remain intentionally redacted from profile exports, so restored connections may require re-entering API keys.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No docs or release metadata changed.

UI evidence (if applicable)

N/A — backend profile export/import route fix. Command proof is listed above.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/887 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/15/2026 **Status:** ✅ Merged **Merged:** 5/15/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `staging` ← **Head:** `fix/issue-847-profile-import-completeness` --- ### 📝 Commits (1) - [`8dcd7cc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8dcd7cc824f6a6bf70209d7cbd2af7272e82e241) Fix profile import completeness ### 📊 Changes **2 files changed** (+402 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/backup.routes.ts` (+185 -2) ➕ `packages/server/test/profile-backup-routes.test.ts` (+217 -0) </details> ### 📄 Description ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #847 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Profile export/import could silently round-trip only a subset of a user's data. Chats, messages, connections, gallery image rows, and other file-native tables were not included in the profile envelope, and semantic lorebook import could leave links pointing at old character IDs. ## What changed <!-- List the key changes in this PR --> - Adds a `fileStorage` snapshot to native profile exports so file-native tables round-trip with stable IDs. - Restores exported profile asset files from `avatars`, `sprites`, `backgrounds`, `gallery`, `fonts`, and `knowledge-sources` during profile import. - Keeps the existing semantic profile importer as the fallback for older exported profile JSON files. - Redacts API connection keys and agent secret-like settings in profile snapshots; connection definitions restore, but API keys still need to be re-entered after import. - Adds a server regression test covering chats, messages, connections, lorebook character links, avatar/gallery files, and API key redaction. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Codex reproduced the bug before the fix with `pnpm --dir packages/server exec tsx ../../scratch/issue-847-profile-roundtrip-repro.ts`: the exported profile lacked a file-native table snapshot, and import restored 0 chats, 0 messages, 0 connections, 0 chat image rows, 0 character image rows, and no gallery files. - Codex re-ran the same scratch repro after the fix. It now exports `fileStorage` and restores 1 chat, 1 message, 1 connection, 1 lorebook character link, 1 chat image row, 1 character image row, the avatar file, and both gallery files. Output saved locally at `scratch/issue-847-after-output.txt`. - Codex ran `pnpm --dir packages/server exec tsx --test test/profile-backup-routes.test.ts`; it passed. - Codex ran `pnpm check`; it passed. - True human/manual limitation: the reporter's real 82.9 MB Google Drive profile was not imported on this machine. The synthetic repro exercises the same profile export/import route and affected data classes. - Security note: API key secrets remain intentionally redacted from profile exports, so restored connections may require re-entering API keys. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) No docs or release metadata changed. ## UI evidence (if applicable) N/A — backend profile export/import route fix. Command proof is listed above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:57 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4823
No description provided.