mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1518] [MERGED] Harden legacy profile import against silent data loss and size limits #5117
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#5117
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1518
Author: @Romuromylus
Created: 5/29/2026
Status: ✅ Merged
Merged: 5/29/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/profile-import-robustness📝 Commits (2)
5f252b7Harden legacy profile import against silent data loss and size limitsa7e068cReject malformed legacy tables and correct the import warning copy📊 Changes
3 files changed (+328 additions, -8 deletions)
View changed files
📝
src-tauri/src/commands/storage/profile/legacy.rs(+217 -1)📝
src-tauri/src/commands/storage/profile/zip_import.rs(+98 -7)📝
src/features/shell/settings/components/ProfileImportSection.tsx(+13 -0)📄 Description
Why this change
Three issues from the Heavy Data / Legacy / Import smoke test (#1484) all live in the profile import path:
caseSensitive,constant,locked,preventRecursion,excludeFromVectorization,selectiveandenabledcame through as"true"/"false"strings, and the filter columns (characterFilterIds,characterTagFilters,additionalMatchingSources,activationConditions) as"[]"strings. The refactor reads these directly, so the entry editor showed the wrong toggle state (a string"false"is truthy in JS) andkeyword-scanner.tsraw-truthiness checks could mis-treat entries as constant or suppress recursion.marinara-profile.jsonwas capped at 128MB, but heavy profiles inline their chat/message tables (and large fields likechats.memories), so a real heavy dataset could never be read.What changed
src-tauri/src/commands/storage/profile/legacy.rs: coerce lorebook-entry bool/array fields to native types during import (matching the field setnormalize_lorebook_entryproduces); only replace collections whose table key is present in the file, so a partial file no longer wipes collections it omits (a present-but-empty table is still an explicit clear).src-tauri/src/commands/storage/profile/zip_import.rs: stream the parse withserde_json::from_readeroff the zip entry instead of buffering the whole file into aVec, reject early on the declared uncompressed size (with.takeas the hard backstop against an understated header), and raise the sanity cap to 1 GiB.src/features/shell/settings/components/ProfileImportSection.tsx: add a destructive confirmation dialog before import.Verification
pnpm check(architecture, frontend, rust, docs) passes locally.cargo test --lib176 passed / 0 failed, including 3 new regression tests: lorebook-entry bool/array coercion, partial-profile no-wipe, and a streaming zip import. The Rust fixes are exercised at the command-function level against the real storage backend.cargo clippy --workspace --all-targets -- -D warningsclean;tsc -bclean.Live
pnpm tauri devnote: the only live path for these fixes is the real profile import, whichreplace_alls the running app's actual storage, so it is not safe to drive automatically against real data. The behavior is covered by the unit tests above (real storage layer on temp dirs). The 1 GiB boundary on a genuinely >128MB profile and the confirm dialog through the native file picker remain a recommended manual pass on a backed-up profile.Follow-ups (deferred, not blocking)
keyword-scanner.tsstill uses raw truthiness forconstant/preventRecursion/caseSensitive. Root-caused here at the import boundary (stored data is now native), but defensive coercion in the scanner could be a separate hardening.data.collectionsimport path has the same full-replace behavior and is tracked separately in #1521.chats.memoriesis stored inline on the chat row and can reach tens of MB on its own. Moving large inline fields out ofmarinara-profile.jsonis a larger format change left for later.Linked issues
Closes #1511
Closes #1512
Closes #1513
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Performance Improvements
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.