Repository navigation
fix: distinct error message when a CouchDB database is missing - #554
Merged
Merged
Conversation
A missing or unreachable database was reported the same way as a wrong key (e.g. 'unknown asset_id', 'work order not found'). On not-found/failure paths the iot, fmsr, wo and vibration servers now report that the database does not exist in this environment and that retrying with other arguments won't help. Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
ShuxinLin
force-pushed
the
feat/couchdb-error-classification
branch
from
September 25, 2026 20:12
5d9b8f2 to
6bbaba3
Compare
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
…heck Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
DhavalRepo18
approved these changes
Sep 25, 2026
This was referenced Sep 28, 2026
Sagar-CK
pushed a commit
to Rohith-Kanathur/AssetOpsBench
that referenced
this pull request
Oct 2, 2026
couchdb3.Database is falsy when its database does not exist (__bool__ sends a HEAD request), so the `if not iot_db` / `if not fm_db` guards fired before the missing-database message from IBM#554 and returned "IoT records database not connected" / "database not connected". With CouchDB unreachable, __bool__ raised instead. Tool guards now go through _missing_db_error (FMSR: check()), helpers test `is None`, and an unknown site is checked against a missing asset registry first, since the registry falls back to ["MAIN"] when it cannot be read. Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
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.
Description
When a CouchDB-backed tool returns nothing, there are two different causes:
Before this PR, both cases produced the same message ("unknown asset_id …", "no records …", "work order not found", "no failure_mode record …"). Agents would keep guessing IDs against a database that doesn't exist.
This PR keeps every wrong-key message as it is. In the missing-database case the tools now return:
The message never contains the database name. Response shapes are unchanged:
ErrorResultstill has justerror.How each server detects a missing database
_missing_db_error(db)runsdb.check()(a HEAD request) only on the not-found and failure paths, before reporting an unknown key. It coversasset_detail,installed_sensors,measured_sensors,history,latest_reading,stream_extent,sensor_coverage,sensor_stats,asset_ids,assetsandfind_assets_by_sensors.CouchClient(get/put/delete/find/view) raisesCouchErrorwith the message above when the 404 reason is "Database does not exist.", instead ofgetreturningNone, which meant "not found".database_available()checks that the database exists before reporting missing data.Notes for reviewers
CouchErrorsurfaces as an MCP tool error (Error executing tool …: the data source does not exist …), not as anErrorResult.get_failure_codeskeeps its existing catalog-unavailable message.database lookup failed …message.sites()still falls back to["MAIN"]when the asset registry is unavailable, so the telemetry tools keep working without it.Type of Change
Testing & Validation
uv run pytest src/ -k "not integration": adds 9 tests, each asserting the wrong-key message and the missing-database message, and that the database name is not in the message. The same 19 tests fail onmainand on this branch (they need a live CouchDB, or are unrelated evaluation/observability tests), so there are no new failures.