From 849bd367b9f419ea89cdd7675aa9d27b0f9c6414 Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Thu, 2 Jul 2026 21:05:23 +0200 Subject: [PATCH] test(triggers): mirror the app_id-not-null inbound guard in the mock (review) Adversarial review NIT: the #[cfg(test)] InMemoryTriggerRepo's email_inbound_target `.expect()`s app_id, which would panic if a future unit test fetched a group-owned email TEMPLATE. Filter `app_id.is_some()` like the production query's `AND t.app_id IS NOT NULL` so the mock stays faithful. Test-only; no production change. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/manager-core/src/triggers_api.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/manager-core/src/triggers_api.rs b/crates/manager-core/src/triggers_api.rs index ab7ee45..06816e6 100644 --- a/crates/manager-core/src/triggers_api.rs +++ b/crates/manager-core/src/triggers_api.rs @@ -1027,9 +1027,12 @@ mod tests { ) -> Result, TriggerRepoError> { let g = self.inner.lock().await; Ok(g.get(&trigger_id) - .filter(|t| t.kind == TriggerKind::Email) + // Mirror the production guard (`email_inbound_target` filters + // `AND t.app_id IS NOT NULL`): a group-owned email TEMPLATE is + // never a valid inbound target. + .filter(|t| t.kind == TriggerKind::Email && t.app_id.is_some()) .map(|t| EmailInboundTarget { - app_id: t.app_id.expect("email trigger is app-owned"), + app_id: t.app_id.expect("filtered to app-owned above"), script_id: t.script_id, enabled: t.enabled, dispatch_mode: t.dispatch_mode,