Repository navigation
fix(search): fail when the broker page query fails - #157
Merged
Merged
Conversation
The paged file lookup collapsed a broker error into the end of the iterator, so an HTTP 500 from the API printed nothing (an info line under --debug) and the command exited 0 with empty output. Yield the error from broker_page_iter, abort the search, and exit 1 with the message. Add a regression test that serves an HTTP 500 from a local listener and asserts the iterator reports one error before ending.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change to distinguish broker API failures from empty search results.
No open issues 🎉
What changed in this PR
Fixes #156 by making monocle search distinguish broker API failures from empty results, so failed page queries no longer silently exit successfully.
Changes:
- Propagates broker page errors, suppresses the completion log, and exits with status 1 after writer and progress-thread cleanup.
- Adds a local HTTP 500 regression test and documents the fix in the changelog.
| File | Description |
|---|---|
src/bin/commands/search.rs |
Adds page-error propagation, failure handling, and an HTTP 500 regression test. |
CHANGELOG.md |
Documents the corrected search failure behavior under Unreleased changes. |
Review effort: Balanced
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.
Fixes #156.
Problem
monocle searchreported success when the broker API failed. Reported command, against an API that answered HTTP 500:No stdout, no stderr. With
--debugthe only trace wasCompleted processing across 0 pages.Cause
The page iterator mapped the broker error onto the end of the iteration:
so "the API failed" and "there are no more files" became the same
None, and the command finished as if the result set were empty.Change
broker_page_iteryieldsResult<Vec<BrokerItem>, String>: oneErron a failed page, then end of iteration. The search loop records the error, skips the completion log, tears down the writer and progress threads, and exits 1:The regression test serves HTTP 500 from a local
TcpListenerand asserts the iterator reports one error and then ends; reverting the propagation makes it fail.Note on the message text: this crate depends on
bgpkit-broker0.10.1, whose client decodes an error body as a success payload and therefore surfaces onlyerror decoding response body.bgpkit/bgpkit-broker#116reports the HTTP status and body instead, so a dependency bump makes the server's own message visible here without another change to this code.Verification
cargo fmt --checkcargo clippy --features cli --bin monocle -- -D warningscargo test --features cli --bin monocle(21 passed, one new)2026-10-20,--broker-files) exits 0 with its 3 files.