mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2709] [Issue]: Game creation robustness — null startingNpcs 500s with no rollback (stuck setup); createGame failure swallowed silently #1354
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#1354
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 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2709
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Two robustness gaps make game-creation failures opaque and unrecoverable: a malformed
startingNpcselement (e.g. anullarray hole) passes validation and then throws a 500 mid-apply with no rollback of the already-created chat (leaving a game stuck insetup); and a/game/createfailure is silently swallowed on the client (no toast, no error) so the user sees the button do nothing.Expected behavior
A bad setup payload should route to the repair modal (or fail cleanly and reset/rollback the chat), and any creation failure should surface a clear error to the user — never a silent no-op or a half-created, stuck game.
Actual behavior
validateGameSetupPayloadonly checksArray.isArray(startingNpcs) && length > 0— never the element shape.applyGameSetupPayloadthen doesn.nameon each element; a[null](or sparse) array throwsTypeError: Cannot read properties of null. The/setuprouteawaitsapplyGameSetupPayloadwith no try/catch, so it 500s (not the 422 repair path). Meanwhile/game/createalready persisted the chat withgameSessionStatus:"setup"and never rolls back, so on reload the client re-enters the setup wizard — a half-created game the user can't escape without manual deletion.useCreateGame.onErroronlyconsole.errors (no toast); the wizard'screateGame.mutatehas anonSuccesschaininggameSetup.mutatebut noonError; there's no globalMutationCacheerror handler. So ifPOST /game/createfails (bad connection, server/validation error),isPendingclears and the button reverts to "Start Game" with no feedback — the user perceives the button as broken.How it breaks the pipeline
Code trace (staging @
b826f8f4):packages/server/src/routes/game.routes.ts:2445-2454(validation, no element check);:3062-3077(map dereferencesn.name);:3686-3693(applyawaited with no try/catch → 500); chat committedsetupat:3336, no rollback; client re-enters wizard viause-game.ts:706; 422-repair path only at:3670-3683(skipped).packages/client/src/hooks/use-game.ts:185-188(onErrorconsole-only);GameSurface.tsx:7937(createGame.mutatehas noonError);main.tsx:13-21(noMutationCachehandler);gameSetupdoes toast on error (use-game.ts:210-217).Steps to reproduce
startingNpcsis[null]or[{...}, null]→/setupreturns 500, no repair modal, chat stuck insetup./game/createreturn a 4xx/5xx → click Start Game → spinner blinks, then the wizard silently returns to idle with no error.Suggested fix
validateGameSetupPayload, verify everystartingNpcsentry is a non-null object with a string name; harden the map (const obj = (n && typeof n==="object") ? n : {}); on bad shape, return the "incomplete — repair the JSON" string so the 422/repair path fires. WrapapplyGameSetupPayloadin try/catch that returns 422 (or resetsgameSessionStatus) so the chat isn't left half-created.onErrortoast to thecreateGame.mutatecall (like the startGame handler), or touseCreateGame.onError, or install a globalMutationCache.onErrorinmain.tsx.Environment
b826f8f4)Additional context
Found via a systematic multi-agent audit of Game Mode. Turns recoverable failures into stuck games and silent no-ops — a big chunk of "failed on game creation" reports. Part of a set of game-mode issues filed together.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@kolacheee commented on GitHub (Jun 21, 2026):
Two clarifications for fixers (core defect, trace, and primary fix are all confirmed present in the current tree):
Scope — there is a SECOND unguarded apply call site the trace omits. The "How it breaks the pipeline" trace cites only the /setup route (line ~3687) for the unguarded
await applyGameSetupPayload(...). The identical pattern —await applyGameSetupPayload(...)with no try/catch, immediately aftervalidateGameSetupPayload(...)— also exists in the /setup/apply-json repair-apply route (validate at ~3726, apply at ~3743). This is the post-repair path: if a user edits the JSON in the repair modal but leaves a bad-shape entry (e.g. startingNpcs still[null]), it passes validation and 500s at the samen.namederef, just at the apply-json call site. Note the primary fix (the validateGameSetupPayload element-shape check) already covers BOTH routes automatically because both validate before applying — so the[null]case is fixed on both paths with that single change. But the secondary suggestion ("wrap applyGameSetupPayload in try/catch") must be applied to BOTH sites (~3687 in /setup AND ~3743 in /setup/apply-json), not just /setup, so a genuine apply-time throw (e.g. a DB write failure) never escapes as a raw 500 on either path.UX precision — the stuck game is escapable, just not cleanly recoverable. The re-entered setup wizard's onCancel handler (GameSurface.tsx ~7964-7971) calls deleteChat.mutate(activeChatId) when sessionStatus === "setup", so the user is not literally trapped "without manual deletion" — they can hit Cancel, which discards the half-created game (and loses all setup progress). The real defect is that the only recovery is abandon-and-restart with no clean repair path, not that the chat is unremovable.
@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in
1ab15210. Setup validation now rejects null/sparse/bad startingNpcs entries before apply, NPC mapping is defensive, both setup apply paths catch apply-time failures into the JSON repair response instead of leaking raw 500s, and create-game failures now show a toast instead of silently resetting the button.