mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3859] [Issue]: Native character import persists invalid cards without schema validation #2087
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#2087
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 @Xelvanis on GitHub (Jul 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3859
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Marinara native character imports accept any nested
dataobject and persist it asCharacterDatawithout runtime schema validation. A malformed native envelope can therefore create a durable character row missing required contract fields such asname.Expected behavior
A file claiming to be a version-1
marinara_characterexport should have its character payload validated against Marinara's canonical character schema before persistence. Missing optional legacy fields may receive schema defaults, while structurally invalid cards should return a normal import failure and create no row.Actual behavior
importCharacter()inpackages/server/src/services/import/marinara.importer.ts:datavalue is an object;Record<string, unknown>;storage.create(... as any).createCharactersStorage().create()trusts its TypeScriptCharacterDataparameter and serializes it directly. TypeScript types do not validate uploaded JSON at runtime, and theanycast suppresses the boundary mismatch.Steps to reproduce
.marinara.jsonfile containing:Imported characterand creates a character whose stored data lacks the requirednamefield and other canonical fields.Environment
Logs, screenshots, or video
No runtime logs or screenshots. Direct schema proof:
Relevant code:
packages/server/src/services/import/marinara.importer.ts: unchecked object clone andstorage.create(charData as any, ...).packages/server/src/services/storage/characters.storage.ts: directJSON.stringify(data)insertion.packages/shared/src/schemas/character.schema.ts: canonicalcharacterDataSchemacontract.Additional context
This laxity is not needed for ordinary third-party character-card compatibility. SillyTavern/Chara Card JSON, PNG, and CharX inputs use the separate
/api/import/st-characterpath and its normalizer./api/import/marinarahandles files explicitly claiming Marinara's native envelope type and version.The character schema is already compatibility-friendly: only
nameis required, missing optional fields receive defaults, and unknown top-level character and extension properties are preserved with passthrough behavior.Suggested direction: call
characterDataSchema.safeParse()at the native import boundary, return the existing structuredInvalid character dataresult when it fails, and persist the validated/normalized value. Compatibility note:characterBookSchemais not currently passthrough, so persistingparsed.datacould strip unknown top-level embedded-lorebook properties. Consider making that schema passthrough or explicitly preserving those properties before adopting normalization.Related but separate: #3858 covers partial character PATCH requests overwriting nested data.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jul 20, 2026):
SpicyMarinara is taking this issue in the current assigned-issue sweep. I’m tracing the reported boundary, adding focused regression coverage, and will link the draft PR here as soon as the proof commit is pushed.
@SpicyMarinara commented on GitHub (Jul 20, 2026):
Implementation is now tracked in draft PR #3862 against
staging.@SpicyMarinara commented on GitHub (Jul 20, 2026):
Addressed in #3862 and merged to staging as
ca6d0c15be.