mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #1571] [Issue]: Generic storage writes can persist malformed lorebook-entry fields #812
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#812
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 @cha1latte on GitHub (May 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1571
Originally assigned to: @Romuromylus on GitHub.
Summary
Generic storage writes can still persist malformed
lorebook-entriesrecords even though the legacy import path now normalizes string booleans and JSON-like arrays.Expected behavior
Every subsystem that writes
lorebook-entriesshould cross one strong record-shape contract. Boolean, array, number, metadata, timing, and scope fields should either be normalized to the native shape or rejected before they reach persistent storage, regardless of whether the row came from the editor, bulk creation, import, tool-generated entries, remote runtime, or another generic storage caller.Actual behavior
The legacy import path was fixed for #1513, but the generic storage boundary remains loosely typed. Source audit against
upstream/refactorfound:src/features/catalog/lorebooks/hooks/use-lorebooks.tscreates, updates, copies, moves, reorders, and bulk-creates lorebook entries throughstorageApiwithRecord<string, unknown>/unknown[]payloads.src/shared/api/storage-api.tsnormalizes stored JSON for chats and messages, but does not normalizelorebook-entries.src/engine/contracts/schemas/lorebook.schema.tsexportscreateLorebookEntrySchemaandupdateLorebookEntrySchema, but current grep found no active call sites using those schemas at the write boundary.src-tauri/src/commands/storage/imports/normalization.rshandles legacy lorebook fields, but that does not protect later genericstorage_create/storage_updatecalls.That means a future or existing caller that bypasses the fixed legacy import path can still hand strings like
"false"or JSON strings like"[\"moon\"]"across the storage boundary and rely on downstream UI/generation code to guess the intended shape.Steps to reproduce
storage_create/storage_updatefor entitylorebook-entries.enabled: "false",constant: "true",keys: "[\"moon\"]", orsecondaryKeys: "[]".search_lorebooktooling.Impact area
Environment
upstream/refactoratab8af081Logs, screenshots, or video
No screenshot. This was found during the focused system-boundary/data-contract audit after #1513 was closed.
Relevant source signals:
src/features/catalog/lorebooks/hooks/use-lorebooks.tssrc/shared/api/storage-api.tssrc/engine/contracts/schemas/lorebook.schema.tssrc-tauri/src/commands/storage/imports/normalization.rsRegression notes
Related to #1513, but not a duplicate. #1513 covered legacy import normalization. This issue covers the remaining generic storage write boundary for lorebook-entry records.
Also related to #1566 because Knip reports the lorebook entry schemas as unused, which is a useful signal that the intended TypeScript contract may not be wired into active write paths.
Additional context
Suggested regression coverage should include at least one positive normalized row and one negative/malformed row for lorebook-entry create/update outside the legacy import path.
Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:
@Romuromylus commented on GitHub (May 30, 2026):
Fixed by #1637, merged into
refactor.