[GH-ISSUE #5407] [Feature]: Return the raw stored text when an experience-state row fails to parse #2996

Closed
opened 2026-10-21 05:58:40 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Aug 22, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5407

Originally assigned to: @kolacheee on GitHub.

What exists today

When a stored experience-state row fails to JSON.parse server-side, GET /api/game/:chatId/experience-state logs a warning and returns { exists: true, state: null, ... } — the raw stored text is dropped from the response.

The problem

The client's correct move on a corrupt row is to write over it (the PUT's replace-per-anchor semantics are the repair). But it can never preserve the corrupt bytes first, because it never sees them — the shape state: null is also indistinguishable from a legitimately stored null. One bad byte on disk means the row's contents are unrecoverable by any client-side means, even though the bytes are sitting right there at parse time.

The ask

When (and only when) the stored text fails to parse, include it in the GET response — e.g. rawState: "<the stored string>" (optionally capped to the route's existing size ceiling) alongside state: null. A package can then quarantine the raw text (Pixelforge would park it in a metadata key for a later fix or bug report) before repairing the row.

Small, read-only, and only on the already-exceptional path. Came out of the Pixelforge S5 (player state) implementation plan.

Originally created by @kolacheee on GitHub (Aug 22, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5407 Originally assigned to: @kolacheee on GitHub. ## What exists today When a stored experience-state row fails to `JSON.parse` server-side, `GET /api/game/:chatId/experience-state` logs a warning and returns `{ exists: true, state: null, ... }` — the raw stored text is dropped from the response. ## The problem The client's correct move on a corrupt row is to write over it (the PUT's replace-per-anchor semantics are the repair). But it can never preserve the corrupt bytes first, because it never sees them — the shape `state: null` is also indistinguishable from a legitimately stored `null`. One bad byte on disk means the row's contents are unrecoverable by any client-side means, even though the bytes are sitting right there at parse time. ## The ask When (and only when) the stored text fails to parse, include it in the GET response — e.g. `rawState: "<the stored string>"` (optionally capped to the route's existing size ceiling) alongside `state: null`. A package can then quarantine the raw text (Pixelforge would park it in a metadata key for a later fix or bug report) before repairing the row. Small, read-only, and only on the already-exceptional path. Came out of the Pixelforge S5 (player state) implementation plan.
bsakaguchi 2026-10-21 05:58:40 +07:00
Author
Owner

@kolacheee commented on GitHub (Aug 22, 2026):

Claiming implementation ownership: kolacheee agent. Working on branch feat/5407-rawstate (fork kolacheee/Marinara-Engine-kolacheee, base staging).

Scope as filed: GET /api/game/:chatId/experience-state will include rawState only on the parse-failure path, capped at the route's existing MAX_EXPERIENCE_STATE_CHARS ceiling (with a rawStateTruncated flag if the stored text somehow exceeds it). The healthy path's response shape is unchanged. Regression coverage goes into the existing scripts/regressions/experience-state.regression.ts lane.

<!-- gh-comment-id:5382472825 --> @kolacheee commented on GitHub (Aug 22, 2026): Claiming implementation ownership: kolacheee agent. Working on branch `feat/5407-rawstate` (fork `kolacheee/Marinara-Engine-kolacheee`, base `staging`). Scope as filed: `GET /api/game/:chatId/experience-state` will include `rawState` **only** on the parse-failure path, capped at the route's existing `MAX_EXPERIENCE_STATE_CHARS` ceiling (with a `rawStateTruncated` flag if the stored text somehow exceeds it). The healthy path's response shape is unchanged. Regression coverage goes into the existing `scripts/regressions/experience-state.regression.ts` lane.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2996
No description provided.