Catch the exception actually thrown when a bucket fails to deserialise - #8371
Merged
Max (maxtropets) merged 4 commits intoSep 14, 2026
Conversation
SeqnosByKey_Bucketed_Untyped::Impl::deserialise catches std::logic_error to treat an unparseable bucket as corrupt, but serialized::read throws InsufficientSpaceException, which derives directly from std::exception. The catch was dead, so a loaded bucket which did not contain a well-formed serialisation escaped as an exception from get_write_txs_in_range, reaching the calling endpoint handler. The bucket remained in the LRU in its loaded state, so every later query touching that range threw again, and the strategy never re-indexed. Catch InsufficientSpaceException instead, which is the only exception that block can throw, so that such a bucket is reported as corrupt and the index is rebuilt. In practice this path is only reachable with content that has passed AES-GCM authentication, so it is defensive rather than attacker controlled. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Amaury Chamayou (achamayou)
September 14, 2026 07:36
View session
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The fix is covered by regression tests and no unresolved issues were identified.
Pull request overview
Fixes malformed LFS bucket handling by catching serialized::InsufficientSpaceException and triggering re-indexing instead of propagating errors.
Changes:
- Catch the correct deserialization exception.
- Add malformed-bucket and recovery regression tests.
File summaries
| File | Description |
|---|---|
src/indexing/test/lfs.cpp |
Adds malformed-bucket and re-indexing recovery tests. |
src/indexing/strategies/seqnos_by_key_bucketed.cpp |
Handles malformed bucket deserialization as corruption. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Max (maxtropets)
approved these changes
Sep 14, 2026
Max (maxtropets)
enabled auto-merge (squash)
September 14, 2026 08:32
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.
SeqnosByKey_Bucketed_Untyped::Impl::deserialisecatchesstd::logic_errorto treat an unparseable bucket as corrupt, butserialized::readthrowsserialized::InsufficientSpaceException, which derives directly fromstd::exception. The catch missed this exception.A loaded bucket that did not contain a well-formed serialisation therefore escaped
get_write_txs_in_rangeas an exception, which the frontend reports as HTTP 500InternalError. Since the bucket stayed in the LRU in itsLoadedstate, every later query touching that range threw again until it was evicted, and the strategy never re-indexed.This catches
InsufficientSpaceExceptioninstead, so malformed bucket contents are reported as corrupt and the index is rebuilt, as intended.ContiguousSet::insertcan still throw allocation or capacity exceptions, includingstd::bad_allocandstd::length_error(which derives fromstd::logic_error). These are left to propagate rather than being misclassified as corruption; rebuilding the index would not address the underlying resource or capacity problem.In practice this path is only reachable with content that has passed AES-GCM authentication and the key-prefix check in
EnclaveLFSAccess, so it is defensive rather than attacker-controlled. Noticed while reviewing #7955.The other
catch (const std::logic_error&)aroundserialized::*calls, inraft.hviaLedgerEnclave::get_entry/skip_entry, is fine:get_entry_sizebounds-checks with its ownstd::logic_errorbefore anyserialized::peek/skip.