mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2138] [Issue]: Game mode — model-JSON parsing uses a weak parser, losing malformed-JSON recovery #1048
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#1048
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 (Jun 4, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2138
Originally assigned to: @cha1latte on GitHub.
Summary
Severity: major. Game-mode LLM-JSON parsing routes through a weak local
parseJsonObjectinstead of the portedparseGameJsonish, so slightly-malformed model output that main auto-recovers fails to parse — and the JSON-repair modal's apply path uses the same weak parser, so it cannot recover either.Expected behavior
As in main: all game LLM-JSON (setup, map, session conclusion, lorebook, campaign progression, cards) funnels through
parseGameJsonish, which tolerates unescaped control chars in strings,////* */comments, trailing/missing commas, code fences, trailing junk (brace-depth extraction), and doubly-stringified JSON.Actual behavior
llmJson(game-api.ts:1614) and the repair-apply path (applyGameJsonRepair,game-api.ts:2876) both callparseJsonObject(game-api.ts:453-474), which only doesJSON.parse/ fenced-regex / naive first-{to last-}slice — norepairJsonish. The faithful portparseGameJsonishexists but is wired only into roleplay/scene paths, never game-mode.Steps to reproduce
//comment, or a raw newline inside a string).{"worldOverview": "line1\nline2", "x": 1,}.Impact area
Environment
refactor@14894608main@c49f1d95(legacy web app)Regression notes
Worked in the legacy web app.
packages/server/src/routes/game.routes.ts:1636-1637(parseJSON->parseGameJsonish), used at 3337/3390/3871/4002/4311/4495/4585/5160. Pipeline:packages/server/src/services/game/jsonish.ts.src/features/modes/game/api/game-api.ts:1614and:2876callparseJsonObject(:453-474). Port exists atsrc/engine/shared/parsing-jsonish.ts:149but is never imported bygame-api.ts. Fix: route both throughparseGameJsonish.