Handle unresolved agent shortnames without UUID errors
This commit is contained in:
@@ -27,7 +27,7 @@ import {
|
|||||||
logActivity,
|
logActivity,
|
||||||
secretService,
|
secretService,
|
||||||
} from "../services/index.js";
|
} 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 { assertBoard, assertCompanyAccess, getActorInfo } from "./authz.js";
|
||||||
import { findServerAdapter, listAdapterModels } from "../adapters/index.js";
|
import { findServerAdapter, listAdapterModels } from "../adapters/index.js";
|
||||||
import { redactEventPayload } from "../redaction.js";
|
import { redactEventPayload } from "../redaction.js";
|
||||||
@@ -152,7 +152,10 @@ export function agentRoutes(db: Db) {
|
|||||||
if (resolved.ambiguous) {
|
if (resolved.ambiguous) {
|
||||||
throw conflict("Agent shortname is ambiguous in this company. Use the agent ID.");
|
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: {
|
function parseSourceIssueIds(input: {
|
||||||
|
|||||||
@@ -264,11 +264,12 @@ export function AgentDetail() {
|
|||||||
const resolvedCompanyId = agent?.companyId ?? selectedCompanyId;
|
const resolvedCompanyId = agent?.companyId ?? selectedCompanyId;
|
||||||
const canonicalAgentRef = agent ? agentRouteRef(agent) : routeAgentRef;
|
const canonicalAgentRef = agent ? agentRouteRef(agent) : routeAgentRef;
|
||||||
const agentLookupRef = agent?.id ?? routeAgentRef;
|
const agentLookupRef = agent?.id ?? routeAgentRef;
|
||||||
|
const resolvedAgentId = agent?.id ?? null;
|
||||||
|
|
||||||
const { data: runtimeState } = useQuery({
|
const { data: runtimeState } = useQuery({
|
||||||
queryKey: queryKeys.agents.runtimeState(agentLookupRef),
|
queryKey: queryKeys.agents.runtimeState(resolvedAgentId ?? routeAgentRef),
|
||||||
queryFn: () => agentsApi.runtimeState(agentLookupRef, resolvedCompanyId ?? undefined),
|
queryFn: () => agentsApi.runtimeState(resolvedAgentId!, resolvedCompanyId ?? undefined),
|
||||||
enabled: Boolean(agentLookupRef),
|
enabled: Boolean(resolvedAgentId),
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: heartbeats } = useQuery({
|
const { data: heartbeats } = useQuery({
|
||||||
|
|||||||
Reference in New Issue
Block a user