Repository navigation
Let hotel search errors reach the API layer instead of masking them - #156
Merged
Merged
Conversation
CouchbaseClient.search_by_name and filter caught every exception, printed it, and fell through. A missing/broken hotel_search index (the SDK raises while streaming rows) therefore returned HTTP 200 [] and looked like "no hotels"; an error raised before the result list existed crashed with UnboundLocalError instead of the real Couchbase error. The client adapter now lets search errors propagate, so error handling lives in one place: the hotel routes, which already map exceptions to 500. Those routes use hotel_ns.abort so the message is not mangled by marshal_with. Adds cluster-free unit tests for both failure modes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nithishr
approved these changes
Nov 19, 2026
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.
What
CouchbaseClient.search_by_nameandCouchbaseClient.filter(src/db.py) no longer catch and swallow search errors. Errors now reach the hotel routes, which already turn exceptions into a 500. Those routes now usehotel_ns.abort(500, ...)so the error message isn't mangled by@marshal_with.Why
Error handling for the hotel search endpoints was split between two layers, and the inner layer hid failures:
mainhotel_searchindex missing/broken (the SDK raises while streaming rows)[], which looks like "no hotels found"{"message": "Unexpected error: QueryIndexNotFoundException(...)"}UnboundLocalError: cannot access local variable 'names', which hides the real Couchbase errorCouchbaseExceptiongoes to the route and comes back as a 500Both rows were observed against a live Couchbase 8.0.3 cluster: start the app, delete the
hotel_searchindex, then call/api/v1/hotel/autocompleteand/api/v1/hotel/filter.Architecturally, the
CouchbaseClientadapter becomes a plain pass-through for search, the same as its KV and query methods. The decision about what an error means for the HTTP response now lives only in the route module.Validation
python -m pytest tests/test_db_search_errors.py: 5 passed. These are new cluster-free unit tests that stub the scope, covering an eager failure and a lazy failure during row iteration. Withmain'sdb.pyrestored, 4 of the 5 fail.couchbase:enterprise-8.0.3(travel-sample, data/index/query/fts), with the app started the same way as in CI: 52 passed (47 existing integration tests and 5 new).🤖 Generated with Claude Code