[superlog] Resolve domain name to UUID in annotation tools#480
[superlog] Resolve domain name to UUID in annotation tools#480superlog-app[bot] wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
The latest updates on your projects. Learn more about Unkey Deploy
|
Greptile SummaryThis PR fixes a
Confidence Score: 4/5The fix is targeted and correct — annotation tools now resolve domains to UUIDs before calling the RPC, matching the existing pattern in the SQL tool. The new test coverage is solid. The core resolution logic works correctly and is well-tested. The domain comparison uses strict equality, which is case-sensitive; if the AI or stored data has mixed casing, the same NOT_FOUND failure could resurface. There is also a minor inconsistency where listAnnotationsTool's error logger still uses the raw websiteId input rather than the resolved UUID. packages/ai/src/ai/tools/utils/context.ts — the case-insensitive domain comparison. Important Files Changed
Sequence DiagramsequenceDiagram
participant AI as AI Agent
participant AT as annotations.ts
participant RW as resolveToolWebsite
participant RPC as annotations RPC
AI->>AT: "listAnnotations/createAnnotation(websiteId = finvzo.com)"
AT->>RW: resolveToolWebsite(ctx, finvzo.com)
RW->>RW: UUID match? no
RW->>RW: "domain match in accessibleWebsites? yes -> web_uuid_123"
RW-->>AT: "{ websiteId: web_uuid_123, domain: finvzo.com }"
AT->>RPC: "list/create({ websiteId: web_uuid_123, ... })"
RPC-->>AT: result
AT-->>AI: success
|
| const byDomain = accessible.find( | ||
| (w) => w.domain != null && w.domain === inputWebsiteId | ||
| ); |
There was a problem hiding this comment.
Domain comparison uses strict equality (
===), but hostnames are case-insensitive per RFC 1034. If the AI returns a domain like "Finvzo.COM" or the stored value has different casing than the input, the lookup silently falls through and throws the "not in this workspace" error — the same failure mode this PR is fixing. Normalising both sides to lowercase is the standard defensive approach.
| const byDomain = accessible.find( | |
| (w) => w.domain != null && w.domain === inputWebsiteId | |
| ); | |
| const normalizedInput = inputWebsiteId.toLowerCase(); | |
| const byDomain = accessible.find( | |
| (w) => w.domain != null && w.domain.toLowerCase() === normalizedInput | |
| ); |
Summary
The insights agent's
create_annotation(andlist_annotations) tool failed withNOT_FOUND: website not foundwhenever the AI passed a domain name (e.g."finvzo.com") aswebsiteIdinstead of the site's UUID. The annotations RPC router stores and looks up websites by UUID, so domain names were never found.The AI learns site domains from the ClickHouse query context and sometimes uses them where the UUID is expected. The
execute_sqltool already handles this correctly (viaresolveToolWebsite+withServerBoundIds), but the annotation tools did not callresolveToolWebsiteat all.Two-part fix:
packages/ai/src/ai/tools/utils/context.ts— extendresolveToolWebsiteto also match by domain name, returning the corresponding UUID fromaccessibleWebsites(or fromctx.websiteDomain/ctx.websiteIdfor single-site contexts). If no match is found by domain either, the existing error is thrown.packages/ai/src/ai/tools/annotations.ts— import and callresolveToolWebsitein bothlistAnnotationsToolandcreateAnnotationToolbefore passingwebsiteIdto the RPC, mirroring the pattern already used inexecute-sql-query.ts.An alternative approach would be to add a Zod pre-process step to the tool's
inputSchemathat normalises thewebsiteIdfield, but fixing it at theresolveToolWebsitelayer is consistent with the existing pattern and benefits all tools that call it.Incident on Superlog
Was this PR helpful? Leave feedback — goes straight to the Superlog team.
Summary by cubic
Fixes annotation tools failing when a website domain is provided instead of a UUID by resolving domains to UUIDs before calling the annotations RPC. Aligns behavior with
execute_sqland removes "website not found" errors.resolveToolWebsiteto accept domains and map them to UUIDs, including single-site contexts; unknown domains still error.resolveToolWebsiteinlistAnnotationsToolandcreateAnnotationToolso RPCs receive the resolvedwebsiteId.Written for commit 403396d. Summary will update on new commits.