-
Notifications
You must be signed in to change notification settings - Fork 187
[superlog] Resolve domain names to UUID before creating annotations #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,15 +27,29 @@ export function resolveToolWebsite( | |||||||||||||||||||||||||||||||
| (id === ctx.websiteId ? ctx.websiteDomain : undefined); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (inputWebsiteId) { | ||||||||||||||||||||||||||||||||
| const isAccessible = | ||||||||||||||||||||||||||||||||
| // Fast path: exact UUID match in the accessible set or the context default | ||||||||||||||||||||||||||||||||
| const isAccessibleById = | ||||||||||||||||||||||||||||||||
| accessible.some((w) => w.id === inputWebsiteId) || | ||||||||||||||||||||||||||||||||
| inputWebsiteId === ctx.websiteId; | ||||||||||||||||||||||||||||||||
| if (!isAccessible) { | ||||||||||||||||||||||||||||||||
| throw new Error( | ||||||||||||||||||||||||||||||||
| `Website "${inputWebsiteId}" is not in this workspace. Call list_websites to see available websites.` | ||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
| if (isAccessibleById) { | ||||||||||||||||||||||||||||||||
| return { websiteId: inputWebsiteId, domain: domainFor(inputWebsiteId) }; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| return { websiteId: inputWebsiteId, domain: domainFor(inputWebsiteId) }; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Slow path: the model may have passed a domain name instead of an id. | ||||||||||||||||||||||||||||||||
| // Check the accessible list first, then the single-site context default. | ||||||||||||||||||||||||||||||||
| const byDomain = accessible.find( | ||||||||||||||||||||||||||||||||
| (w) => w.domain != null && w.domain === inputWebsiteId | ||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
| if (byDomain) { | ||||||||||||||||||||||||||||||||
| return { websiteId: byDomain.id, domain: byDomain.domain ?? undefined }; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| if (inputWebsiteId === ctx.websiteDomain && ctx.websiteId) { | ||||||||||||||||||||||||||||||||
|
Comment on lines
+40
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||
| return { websiteId: ctx.websiteId, domain: ctx.websiteDomain }; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| throw new Error( | ||||||||||||||||||||||||||||||||
| `Website "${inputWebsiteId}" is not in this workspace. Call list_websites to see available websites.` | ||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| const fallbackId = ctx.defaultWebsiteId ?? ctx.websiteId; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?? undefinedis dead code here: thefindpredicate already guardsw.domain != null, sobyDomain.domainis always a non-null string at this point. The nullish coalescing just adds noise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!