Skip to content

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

fix(security): skip denying an agent's approvals when no approval store exists (#7032)

oxoxDev3035d0b3710a
diff --git a/crates/openhuman-core/src/security/approval/gate_state.rs b/crates/openhuman-core/src/security/approval/gate_state.rs
index e6e68028a8..b89655d2e5 100644
--- a/crates/openhuman-core/src/security/approval/gate_state.rs
+++ b/crates/openhuman-core/src/security/approval/gate_state.rs
@@ -117,6 +117,9 @@ impl ApprovalGate {
/// Deny every undecided request `agent` parked, resolving its waiters.
/// Returns how many rows were denied.
pub fn deny_all_for_agent(&self, agent: &str, resolution: &str) -> anyhow::Result<usize> {
+ if !store::exists(&self.config) {
+ return Ok(0);
+ }
let rows = store::list_pending_for_agent(&self.config, Some(agent))?;
let mut denied = 0;
for row in rows {
diff --git a/crates/openhuman-core/src/security/approval/store.rs b/crates/openhuman-core/src/security/approval/store.rs
index 446d1d8006..feb2c17575 100644
--- a/crates/openhuman-core/src/security/approval/store.rs
+++ b/crates/openhuman-core/src/security/approval/store.rs
@@ -197,8 +197,17 @@ fn migrate_session_id_scrub(conn: &Connection) -> Result<()> {
/// Open (and migrate) the approval DB, then call `f` with a live
/// connection. Mirrors `notifications/store.rs::with_connection`.
+fn db_path(config: &Config) -> std::path::PathBuf {
+ config.workspace_dir.join("approval").join("approval.db")
+}
+
+/// Whether the approval store has been created for `config`'s workspace.
+pub fn exists(config: &Config) -> bool {
+ db_path(config).is_file()
+}
+
fn with_connection<T>(config: &Config, f: impl FnOnce(&Connection) -> Result<T>) -> Result<T> {
- let db_path = config.workspace_dir.join("approval").join("approval.db");
+ let db_path = db_path(config);
tracing::trace!(
path = %db_path.display(),