mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3051] [Issue]: ImportPersonaModal drops personaStats when imported JSON stores it as an object (uses stringField instead of jsonStringField like every sibling JSON field) #1620
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#1620
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 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3051
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
In the plain-JSON import branch of ImportPersonaModal, every persona field holding a JSON object/array is normalized via
jsonStringField()EXCEPTpersonaStats, which usesstringField().stringField()returns the value only if it is already a string and returns""for anything else (objects/arrays). So if an imported JSON file representspersonaStatsin its natural in-memory object shape ({ enabled, bars, rpgStats? }) rather than a pre-stringified JSON string, the persona's entire status-bar / RPG-stats configuration is silently discarded and the persona is created withpersonaStats = "". The three structurally identical sibling fields right next to it (trackerCardColors,tags,savedStatusOptions) all correctly accept the object form viajsonStringField, making this a clear inconsistency rather than a deliberate choice. (Marinara's own native/compatible exports serialize personaStats as a string and round-trip fine; this bites third-party / hand-authored / older-format JSON.)How to reproduce (try it yourself)
{ "name": "Test", "personaStats": { "enabled": true, "bars": [{ "name": "Energy", "value": 80, "max": 100, "color": "#22c55e" }] } }.You'll see: the status bars / RPG stats are gone; the Stats tab shows defaults (disabled), because
stringField(json.personaStats)saw an object and returned"".Expected: the imported personaStats object is preserved (serialized to its JSON-string storage form).
Where it is
packages/client/src/components/modals/ImportPersonaModal.tsx:114—personaStats: stringField(json.personaStats),(helpers at:16-18and:27-31; correct siblings at:113,:115,:116).packages/shared/src/types/persona.ts:33(PersonaStatsConfig).packages/server/src/services/storage/characters.storage.ts:419; DB default:packages/server/src/db/schema/characters.ts:65.What's happening
personaStatsis a JSON-encoded structured field (DB column stores a JSON string; in-memory shape isPersonaStatsConfig). The import mapper treats it as plain text viastringField(), which only passes through already-stringified values and yields""for the object form, while the adjacent fields usejsonStringField()which JSON.stringifies arrays/objects.Suggested fix
Map
personaStatswithjsonStringFieldlike its three siblings. At ImportPersonaModal.tsx:114 changepersonaStats: stringField(json.personaStats),topersonaStats: jsonStringField(json.personaStats, ""),. This keeps already-stringified values as-is (Marinara exports round-trip byte-identically) and additionally JSON.stringifies the natural object form so hand-authored / non-Marinara JSON keeps its stats. The""fallback matches the DB default and guarantees a string is sent, satisfying the server'spersonaStats?: stringcontract. Regression notes:jsonStringFieldpasses strings through unchanged and returns""for null/undefined/absent/number/boolean — identical to the currentstringFieldresult and the server/DB default — so the happy path and all empty-stats edge cases are unchanged; the only behavior change is the intended one (object-form stats now preserved).AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Claiming this for the current staging sweep in draft PR #3053 (branch
codex/issue-sweep-3033-3052).@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in PR #3053 on branch
codex/issue-sweep-3033-3052(commitbfb1bc76). Closing this issue as addressed; the PR remains open for staging review/merge.