mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5610] [MERGED] fix(storage): treat valid-JSON non-array shard roots as corruption #6846
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#6846
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5610
Author: @kolacheee
Created: 8/28/2026
Status: ✅ Merged
Merged: 8/28/2026
Merged by: @kolacheee
Base:
staging← Head:fix/5601-non-array-roots📝 Commits (2)
cf6bae2fix(storage): treat valid-JSON non-array shard roots as corruption7c48582fix(storage): quarantine an unrecoverable monolith during migration📊 Changes
3 files changed (+156 additions, -9 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/server/src/db/file-backed-store.ts(+49 -9)📝
scripts/regressions/message-sharding.regression.ts(+106 -0)📄 Description
Why
Closes #5601 (found during #5597's review cycle; the behavior is identical in the pre-lazy eager loader, so it has existed since sharding).
echo '{}' > <chat-shard>.jsonmade that chat silently render empty — no log, no quarantine — even with a perfectly good.baknext to it.Independent of #5609 — based directly on staging; the two touch disjoint regions and merge in either order.
What
parseJsonFilegains an optional root validator whose failure throws inside the same read step asJSON.parse— so shape corruption reuses the existing recovery ladder verbatim: primary fails →.bakis tried (and validated); both bad → fallback withunreadablePaths, which the existing downstream machinery turns into a.corrupt-*quarantine. All five row-array call sites passArray.isArray: the eager boot loop, the lazy unit loader, the flat-table loop, the messages harvest (so id-scoped queries see backup-recovered rows too), and the monolith migration read. The manifest reader deliberately keeps its tolerant handling — its consumers already treat junk defensively and its root is an object.Recovery composes with the existing heal: a backup-recovered shard is dirtied, the next flush rewrites the primary from the recovered rows with backup-refresh suppressed, so the corrupt primary can never clobber the good
.bak(same #4708-era contract).Regressions
Two new blocks in
message-sharding.regression.ts(runs in both lazy and eager modes): non-array primary + valid backup → rows recover, id-scoped harvest reads work, healing flush rewrites the primary and never touches the backup; non-array primary with no backup → quarantined under.corrupt-*instead of silently kept. Verified red against the pre-fix store on the issue's exact symptom. Lazy suite, shutdown, and slurp lanes green.Test plan
pnpm checkon a non-Windows checkoutpnpm regression{}, restart — with a.bakpresent the chat recovers; without one the file lands in.corrupt-*and the log says soSummary by CodeRabbit
Bug Fixes
Tests
Documentation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.