Skip to content

#558 widen sqlite_store rescue to cover JSON::ParserError#570

Open
edmoffo wants to merge 1 commit into
zerocracy:masterfrom
edmoffo:558-widen-rescue
Open

#558 widen sqlite_store rescue to cover JSON::ParserError#570
edmoffo wants to merge 1 commit into
zerocracy:masterfrom
edmoffo:558-widen-rescue

Conversation

@edmoffo

@edmoffo edmoffo commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Fbe::Middleware::SqliteStore#read previously rescued only Zlib::Error, so a deflate stream that decoded into a non-JSON payload — partial writes, SQLite corruption recovery, leftover rows from older serializations — escaped as JSON::ParserError from read and crashed Faraday::HttpCache on every subsequent lookup for that key. The poisoned row stayed in the database because the existing delete(key) branch only ran on a Zlib failure, so until something else evicted the key the middleware was wedged on it.

The rescue is widened to also catch JSON::ParserError and TypeError, and the log line is renamed from Failed to decompress to Failed to decode to cover both branches. delete(key) still runs, so the next request rebuilds the entry from the network.

A regression test in test/fbe/middleware/test_sqlite_store.rb writes a valid deflate stream of a non-JSON payload directly through the store's SQLite handle and asserts that read(key) returns nil and that all reports an empty cache. Ran bundle exec ruby -Ilib -Itest test/fbe/middleware/test_sqlite_store.rb locally — 24 tests pass — and bundle exec rubocop is clean on both touched files.

Closes #558


Generated by Claude Code

`Fbe::Middleware::SqliteStore#read` rescued only `Zlib::Error`, so a deflated row that did not contain valid JSON crashed `Faraday::HttpCache` on every subsequent lookup. Catch `JSON::ParserError` and `TypeError` as well so the poisoned row is dropped and the next request rebuilds the entry.

Closes zerocracy#558
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fbe::Middleware::SqliteStore#read raises JSON::ParserError on corrupted cached value despite the Zlib rescue

1 participant