From b05154adcec2444814aa3b3f2ed8df71d15ff7d6 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Thu, 19 Nov 2026 18:02:15 +0100 Subject: [PATCH] fix(registry): a 404 for a tenant's connections lists none (#1028) Before tenant-registry#138 the registry has no connections route; the release screen would warn on every visit that connections cannot be read. A 404 now lists no connections; other errors still answer 503. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9 --- compliance-agent/src/registry.rs | 8 +++++++- compliance-agent/tests/connections.rs | 12 +++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/compliance-agent/src/registry.rs b/compliance-agent/src/registry.rs index 59c95af..e9e9267 100644 --- a/compliance-agent/src/registry.rs +++ b/compliance-agent/src/registry.rs @@ -631,7 +631,8 @@ impl RegistryClient { /// /// # Errors /// - /// The registry could not be asked, or answered with an error. + /// The registry could not be asked, or answered with an error other than + /// 404. pub async fn active_connections(&self, tenant_id: &str) -> Result, String> { #[derive(Deserialize)] struct Page { @@ -650,6 +651,11 @@ impl RegistryClient { .send() .await .map_err(|e| format!("connection list failed: {e}"))?; + // A registry without connections for the tenant (or, before + // tenant-registry#138, without the route) has none to list. + if resp.status() == reqwest::StatusCode::NOT_FOUND { + return Ok(Vec::new()); + } if !resp.status().is_success() { return Err(format!("connection list returned {}", resp.status())); } diff --git a/compliance-agent/tests/connections.rs b/compliance-agent/tests/connections.rs index 8c57d76..d190ab0 100644 --- a/compliance-agent/tests/connections.rs +++ b/compliance-agent/tests/connections.rs @@ -32,7 +32,8 @@ use compliance_core::{OrgRole, TenantContext, TenantStatus}; use common::dev_config; /// A registry where tenant `t-1` is connected to two workspaces and -/// connection `c-ended` has ended; `t-down` cannot be listed; `t-3` does not +/// connection `c-ended` has ended; `t-down` cannot be listed, `t-unknown` +/// is not known (404); `t-3` does not /// hold Prüfwerk. async fn fake_registry() -> String { let app = Router::new() @@ -45,6 +46,7 @@ async fn fake_registry() -> String { { "id": "c-1", "peer_tenant_id": "t-2", "peer_name": "beispiel Maschinenbau" }, ] }))), "t-down" => Err(StatusCode::INTERNAL_SERVER_ERROR), + "t-unknown" => Err(StatusCode::NOT_FOUND), _ => Ok(Json(serde_json::json!({ "items": [] }))), } }), @@ -148,6 +150,14 @@ async fn the_client_lists_and_checks_connections() { assert_eq!(listed.len(), 2); assert_eq!(listed[1].peer_tenant_id, "t-2"); assert!(registry.active_connections("t-down").await.is_err()); + assert!( + registry + .active_connections("t-unknown") + .await + .unwrap() + .is_empty(), + "a 404 lists none" + ); let c1 = registry.connection("c-1").await.unwrap().unwrap(); assert_eq!(c1.peer_of("t-1"), Some("t-2"));