Skip to content

fix(cache): recover from corrupt scalar entries - #2828

Merged
openai0229 merged 2 commits into
OtterMind:mainfrom
HandSonic:fix/cache-corrupt-fallback
Sep 15, 2026
Merged

openai0229 merged 2 commits into
OtterMind:mainfrom
HandSonic:fix/cache-corrupt-fallback

Conversation

@HandSonic

@HandSonic HandSonic commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

N/A - no matching issue was found.

Summary

A malformed scalar JSON entry escaped CacheManage before the configured fallback loader could run, so the same cache key remained unusable for its TTL. This change catches scalar deserialization failures, removes only the corrupt key, and lets the existing fallback path rebuild and cache a valid value.

Affected surfaces

  • Frontend / Web
  • Backend / API / Storage
  • Database plugin / Driver
  • JCEF / Desktop packaging
  • CI / Build / Release
  • Documentation only

Verification

  • Current main reproduced JSONException: input end before the fallback loader: 6 tests, 1 error before the fix.
  • Integrated head owning reactor tests and package passed: domain-core 306, SPI 147, tools 77, domain-api 27; 557 total, zero failures/errors/skips.
  • Command: mvn -B -ntp -f chat2db-community-server/pom.xml -pl :chat2db-community-domain-core -am -Dmaven.test.skip=false -DskipTests=false '-Dsurefire.includes=**/*Test.java' -Dsurefire.failIfNoSpecifiedTests=false -Dmaven.test.failure.ignore=false package. Test JVM home/temp were isolated.
  • An additional temporary review test passed for neighboring-key preservation, loader exception propagation and subsequent recovery; it is not part of this PR.
  • Executable backend package passed. Playwright CLI created a SQLite connection, warmed the actual scalar metadata cache, and verified recovery after a test-only attach agent injected malformed JSON into that exact datasource key. First request, repeat request and reload passed; the underlying cache value was verified as valid JSON afterward.
  • This verifies recovery from an injected corrupt value, not a claim that ordinary user actions naturally produce corrupt JSON.
  • The two integrated PR files are byte-identical to the Web-tested version. Current-head checks are available below.

Risk and compatibility

  • Public API or stored data: No API or cache format changes; only an unreadable key is evicted.
  • Database or driver compatibility: N/A.
  • Network, privacy, or security: N/A.
  • Community / Local / Pro boundary: Shared Community metadata cache.
  • Backward compatibility: Valid scalar and list entries retain existing behavior.

Reviewer map

  • Start here: CacheManage.CacheStore.get and the corrupt scalar regression case.
  • Failure condition: malformed JSON escapes before fallback or a valid neighboring key is removed.
  • Rollback or disable path: Revert commit 8618ac7e9edd87667ac9c0674f6b5516922956e3; no migration is required.

Contributor declaration

  • I linked the Issue that defines this change.
  • I tested the affected behavior and reported the actual results above.
  • I did not include credentials, private data, or generated build output.
  • I disclosed substantial AI assistance below, or this PR contains no substantial AI-generated code.

AI assistance: OpenAI Codex assisted with diagnosis, implementation, automated tests, verification, and adversarial review.

@HandSonic
HandSonic requested review from a team and openai0229 as code owners August 30, 2026 17:49
@openai0229 openai0229 moved this to In Review in Chat2DB Community Aug 30, 2026
@HandSonic
HandSonic force-pushed the fix/cache-corrupt-fallback branch from cfd756e to 8618ac7 Compare September 3, 2026 18:20
@openai0229
openai0229 merged commit 579a787 into OtterMind:main Sep 15, 2026
18 of 19 checks passed
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants