Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(doctor): the MongoDB probe also proves read access; keep SQLite behind legacy-import

M3gA-Mind8618c9526f41
diff --git a/crates/openhuman-core/Cargo.toml b/crates/openhuman-core/Cargo.toml
index 8e242161a5..1a0c5330b9 100644
--- a/crates/openhuman-core/Cargo.toml
+++ b/crates/openhuman-core/Cargo.toml
@@ -125,8 +125,10 @@ tinyagents-storage-kit = { path = "../../vendor/tinyagents/crates/tinyagents-sto
tinystoragedrivers = { git = "https://github.com/tinyhumansai/tinystoragedrivers", rev = "05eaada962decbab33bafa4763d2bd1a67f6b456", default-features = false }
tinystoragedrivers-api = { git = "https://github.com/tinyhumansai/tinystoragedrivers", rev = "05eaada962decbab33bafa4763d2bd1a67f6b456" }
# Legacy source readers use the shared SQLite binding only while the host
-# migration feature is enabled; production storage opens through the facade.
-tinystoragedrivers-connect = { git = "https://github.com/tinyhumansai/tinystoragedrivers", rev = "05eaada962decbab33bafa4763d2bd1a67f6b456", features = ["sqlite"], optional = true }
+# migration feature is enabled (`legacy-import`); the doctor's MongoDB probe
+# uses its hello-only connection (`storage-mongodb`). Production storage opens
+# through the facade.
+tinystoragedrivers-connect = { git = "https://github.com/tinyhumansai/tinystoragedrivers", rev = "05eaada962decbab33bafa4763d2bd1a67f6b456", optional = true }
tinystoragedrivers-types = { git = "https://github.com/tinyhumansai/tinystoragedrivers", rev = "05eaada962decbab33bafa4763d2bd1a67f6b456" }
# The host config and secret adapters use the driver's established `enc2`
# codec and per-scope key provider while storing through the v2 SecretStore
@@ -562,7 +564,7 @@ langfuse = ["tinyagents-harness/langfuse"]
# it on. OS keychain support belongs to openhuman-rpc's `os-keyring` feature,
# not the core or its storage-driver feature set.
storage-sqlite = ["tinystoragedrivers/sqlite"]
-legacy-import = ["dep:tinystoragedrivers-connect"]
+legacy-import = ["dep:tinystoragedrivers-connect", "tinystoragedrivers-connect/sqlite"]
storage-mongodb = ["tinystoragedrivers/mongodb", "dep:tinystoragedrivers-connect", "tinystoragedrivers-connect/mongodb"]
# `s3://` blob URLs and composite storage. In neither the contributor set nor
# the product: an object-store client is only for a deployment that wants one.
diff --git a/crates/openhuman-core/src/doctor/checks/storage.rs b/crates/openhuman-core/src/doctor/checks/storage.rs
index b1eba5bf18..707505f13d 100644
--- a/crates/openhuman-core/src/doctor/checks/storage.rs
+++ b/crates/openhuman-core/src/doctor/checks/storage.rs
@@ -84,20 +84,29 @@ async fn inspect_storage_config(check_id: &str, config: StorageConfig) -> Vec<Fi
StorageConfig::MongoDb { uri, database } => {
#[cfg(feature = "storage-mongodb")]
{
- // `hello` only. `tinystoragedrivers::open` would create the
- // driver's collections and indexes, which a read-only probe
- // must not do and a read-only credential can't.
- match tinystoragedrivers_connect::MongoConnection::connect(&uri, &database).await {
- Ok(connection) => {
- drop(connection);
- vec![Finding::pass(
- check_id,
- "The selected MongoDB server answered a read-only hello request.",
- )]
- }
+ // `hello`, then a collection listing to prove the credential
+ // can read the selected database. `tinystoragedrivers::open`
+ // would create the driver's collections and indexes, which a
+ // read-only probe must not do and a read-only credential can't.
+ let probe = async {
+ let connection =
+ tinystoragedrivers_connect::MongoConnection::connect(&uri, &database)
+ .await
+ .map_err(|_| ())?;
+ connection
+ .database()
+ .list_collection_names()
+ .await
+ .map_err(|_| ())
+ };
+ match probe.await {
+ Ok(_) => vec![Finding::pass(
+ check_id,
+ "The selected MongoDB database answered read-only hello and listing requests.",
+ )],
Err(_) => vec![Finding::error(
check_id,
- "The selected MongoDB server could not be reached.",
+ "The selected MongoDB database could not be reached or read.",
"Check the selected MongoDB endpoint and credentials.",
)],
}
diff --git a/crates/openhuman-core/src/doctor/checks/storage_tests.rs b/crates/openhuman-core/src/doctor/checks/storage_tests.rs
index 94679d0869..fc14a37af7 100644
--- a/crates/openhuman-core/src/doctor/checks/storage_tests.rs
+++ b/crates/openhuman-core/src/doctor/checks/storage_tests.rs
@@ -82,7 +82,12 @@ async fn mongodb_connect_probe_creates_nothing_in_the_inspected_database() {
);
return;
};
- let database = format!("oh_doctor_probe_{}", std::process::id());
+ // Unique per run, and dropped below only if the probe itself created it.
+ let nanos = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .unwrap()
+ .as_nanos();
+ let database = format!("oh_doctor_probe_{}_{nanos}", std::process::id());
let findings = inspect_storage_config(
"storage/connect",
StorageConfig::MongoDb {
@@ -96,7 +101,9 @@ async fn mongodb_connect_probe_creates_nothing_in_the_inspected_database() {
.expect("test client")
.database();
let created = db.list_collection_names().await.expect("list collections");
- let _ = db.drop().await;
+ if !created.is_empty() {
+ let _ = db.drop().await;
+ }
assert_eq!(findings[0].severity, FindingSeverity::Pass);
assert!(
created.is_empty(),