#558 widen sqlite_store rescue to cover JSON::ParserError#570
Open
edmoffo wants to merge 1 commit into
Open
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fbe::Middleware::SqliteStore#readpreviously rescued onlyZlib::Error, so a deflate stream that decoded into a non-JSON payload — partial writes, SQLite corruption recovery, leftover rows from older serializations — escaped asJSON::ParserErrorfromreadand crashedFaraday::HttpCacheon every subsequent lookup for that key. The poisoned row stayed in the database because the existingdelete(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::ParserErrorandTypeError, and the log line is renamed fromFailed to decompresstoFailed to decodeto 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.rbwrites a valid deflate stream of a non-JSON payload directly through the store's SQLite handle and asserts thatread(key)returnsniland thatallreports an empty cache. Ranbundle exec ruby -Ilib -Itest test/fbe/middleware/test_sqlite_store.rblocally — 24 tests pass — andbundle exec rubocopis clean on both touched files.Closes #558
Generated by Claude Code