From 63c0e22a2a5a7adeb69ae69d822717762116a4dd Mon Sep 17 00:00:00 2001 From: Dotta Date: Fri, 6 Mar 2026 09:06:55 -0600 Subject: [PATCH] Handle unresolved agent shortnames without UUID errors --- server/src/routes/agents.ts | 7 +++++-- ui/src/pages/AgentDetail.tsx | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/server/src/routes/agents.ts b/server/src/routes/agents.ts index 607c451a..233b27b7 100644 --- a/server/src/routes/agents.ts +++ b/server/src/routes/agents.ts @@ -27,7 +27,7 @@ import { logActivity, secretService, } from "../services/index.js"; -import { conflict, forbidden, unprocessable } from "../errors.js"; +import { conflict, forbidden, notFound, unprocessable } from "../errors.js"; import { assertBoard, assertCompanyAccess, getActorInfo } from "./authz.js"; import { findServerAdapter, listAdapterModels } from "../adapters/index.js"; import { redactEventPayload } from "../redaction.js"; @@ -152,7 +152,10 @@ export function agentRoutes(db: Db) { if (resolved.ambiguous) { throw conflict("Agent shortname is ambiguous in this company. Use the agent ID."); } - return resolved.agent?.id ?? raw; + if (!resolved.agent) { + throw notFound("Agent not found"); + } + return resolved.agent.id; } function parseSourceIssueIds(input: { diff --git a/ui/src/pages/AgentDetail.tsx b/ui/src/pages/AgentDetail.tsx index 7c8c6b19..56069013 100644 --- a/ui/src/pages/AgentDetail.tsx +++ b/ui/src/pages/AgentDetail.tsx @@ -264,11 +264,12 @@ export function AgentDetail() { const resolvedCompanyId = agent?.companyId ?? selectedCompanyId; const canonicalAgentRef = agent ? agentRouteRef(agent) : routeAgentRef; const agentLookupRef = agent?.id ?? routeAgentRef; + const resolvedAgentId = agent?.id ?? null; const { data: runtimeState } = useQuery({ - queryKey: queryKeys.agents.runtimeState(agentLookupRef), - queryFn: () => agentsApi.runtimeState(agentLookupRef, resolvedCompanyId ?? undefined), - enabled: Boolean(agentLookupRef), + queryKey: queryKeys.agents.runtimeState(resolvedAgentId ?? routeAgentRef), + queryFn: () => agentsApi.runtimeState(resolvedAgentId!, resolvedCompanyId ?? undefined), + enabled: Boolean(resolvedAgentId), }); const { data: heartbeats } = useQuery({