mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #1180] Pre-refactor data migration: five import gaps drop or corrupt legacy user data #583
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#583
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 @Romuromylus on GitHub (May 24, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1180
Originally assigned to: @Romuromylus on GitHub.
While testing whether existing users on the pre-refactor
stagingbranch can move their data to the Tauri refactor, I hit five separate import gaps that either drop data silently, crash the editor, or block the full-profile zip outright. They share a single theme: the refactor's importers and modals don't account for the schema and envelope shapes the production app actually ships.Filing them as one issue since they're all the migration path and the fix in # addresses them together.
The five gaps (refactor branch HEAD
7ea792d8)1. Profile zip import rejects every backup that contains chat images
PROFILE_ASSET_DIRSinsrc-tauri/src/commands/storage/profile/assets.rslistsavatars / sprites / backgrounds / game-assets / fonts / knowledge-sources / lorebooks/images. The pre-refactorBACKUP_DIRSset inpackages/server/src/routes/backup.routes.tsalso includesgallery(chat image attachments). When the refactor walks the zip and validates each asset entry throughsafe_profile_asset_path, the firstgallery/entry trips the allow-list and the whole import aborts withInvalid profile asset path. This affects every user who has attached an image to a chat, which is the common case.2. SillyTavern chat import sets an invalid
modevalueimport_st_chat_textinsrc-tauri/src/commands/storage/imports/bulk_imports.rsdefaults the new chat'smodeto the literal string"chat"when the JSONL header doesn't supply one. TheChatModeenum isconversation | roleplay | visual_novel | game, and the mode sidebars filter on it; chats imported via this path get created in storage but never appear in any sidebar, only on the Recent surface.3. Marinara lorebook envelope importer doesn't normalize legacy text-encoded array fields
import_marinara_lorebookinsrc-tauri/src/commands/storage/imports/marinara.rswrites the lorebook row throughwith_entity_defaults, which only fills missing keys. The pre-refactor schema storestags,characterIds, andpersonaIdsas TEXT columns containing JSON-stringified arrays (e.g."[]"or'["foo","bar"]'). The string passes through to storage untouched, and the moment the user opens the imported lorebook the editor crashes:The same shape mismatch hits the legacy profile-zip path through
add_legacy_lorebook_linksinsrc-tauri/src/commands/storage/profile/legacy.rswhenever the source row carries those fields directly.4. ImportPresetModal and ImportLorebookModal silently downgrade unknown
marinara_*envelopes to empty SillyTavern recordsBoth modals detect the Marinara envelope shape with a strict-equality check (
json.type === "marinara_preset"andjson.type === "marinara_lorebook"). The pre-refactor app exports seven envelope types in total (marinara_character,marinara_persona,marinara_lorebook,marinara_preset,marinara_chat_preset,marinara_memory_recall,marinara_profile). When a user drops amarinara_chat_presetormarinara_memory_recallfile into the preset modal, the strict check fails, the file falls through toimportApi.stPreset, the permissive ST importer accepts the JSON and creates a row with zero sections / zero groups / zero choice blocks, and the modal reports "Imported preset" with full UI success. The user thinks the file imported; the data is gone.The persona and character modals already use the broader
startsWith("marinara_")check, so they correctly route unsupported envelopes to the Marinara importer where the Rust router rejects them with a real error.5. Rust router has no handlers for
marinara_chat_presetormarinara_memory_recallimport_marinara_envelopeinsrc-tauri/src/commands/storage/imports/marinara.rsmatches on the four supported envelope types and rejects everything else withUnknown Marinara import type: <type>. The two missing types are real pre-refactor export endpoints (/api/chat-presets/:id/exportand/api/chats/:id/memories/export). Fixing (4) above is enough to make the user see this rejection as a clear error instead of a silent empty-record success; adding actual handlers is the longer-term path and a separate scope from this PR.Reproduction
Fabricate the test files from a snapshot of the production data tables, then drop them through the corresponding refactor import dialogs in
pnpm tauri dev. Test counts that round-trip cleanly after this fix:tagsparsed, editor opens)Linked PR
I've opened a draft PR with the consolidated fix; linking back here once it has a number.
@Romuromylus commented on GitHub (May 24, 2026):
Linked PR: #1181 (draft). Will promote out of draft after the live drag-drop verification across all five paths in
pnpm tauri dev.@Romuromylus commented on GitHub (May 24, 2026):
Adding a sixth gap to the same PR after live retest exposed it:
6. All avatars render broken after a profile zip import
Pre-refactor's
charactersandpersonastables storeavatarPathas the old server route (e.g./api/avatars/file/<uuid>.png). The refactor's legacy importer normalizes those URLs into the new relative form vianormalize_legacy_profile_asset_paths, gated on the asset file existing atstate.data_dir.join(relative). PR #1153 / #1179 (atomic asset transaction) staged restored assets under a temporarystaging_rootand only moved them intostate.data_dirafter the database rows had been written, so the existence check missed every just-restored avatar and the rows kept the unresolvable URLs. Symptom: profile zip imports complete successfully, but every character and persona renders with a broken avatar across the whole library.Fix in #1181 threads an
Option<&Path>staging root through the normalizer and accepts the asset as present if the file is in either the staging dir or the live data dir.@Romuromylus commented on GitHub (May 24, 2026):
Two more gaps surfaced during live retest and are now part of #1181:
7. Lorebook list and editor show every imported lorebook as
GlobalPre-refactor stored bool columns on lorebook rows (
isGlobal,enabled,recursiveScanning,excludeFromVectorization) as TEXT with literal"true"/"false"strings. The refactor'swith_entity_defaultsonly fills the field when missing, so the strings flow into storage unchanged. JavaScript treats every non-empty string as truthy, solorebook.isGlobal === "false"evaluates totrueand the library renders every scoped lorebook as global. (Symptom: 25 of 32 lorebooks taggedGlobalpost-import, vs the 5 that were actually global in the source.) Fixed by addingnormalize_legacy_text_bool_fieldstoshared.rsand invoking it on the lorebook row from both the marinara-envelope path and the legacy profile-zip path.8. Roleplay-mode chats with lorebooks error with
Invalid collection namebuildActivatedEntriesinsrc/engine/generation/prompt-assembly.tscalledstorage.list(lorebooks/${id}/entries). That path shape is a leftover from the pre-refactor HTTP API; the refactor storage layer rejects anything with a slash viavalidate_collection_nameincrates/security/src/lib.rs. Any roleplay-mode chat with one or more attached lorebooks surfacedInvalid collection name: lorebooks/<id>/entriesthe moment the user sent a message. Fixed by switching to the existinglistLorebookEntries(lorebookId)capability, matching the shape every other refactor caller uses.