[superlog] Add manage:websites scope to insights agent service auth#471
[superlog] Add manage:websites scope to insights agent service auth#471superlog-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: 5/5Safe to merge — the change adds a single scope string to a service auth context to match what the agent's always-enabled write tools already require. The fix is a one-line addition of No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Job as insights-generate-website job
participant Agent as ToolLoopAgent
participant RPC as annotations.create / goals.update
participant Auth as withWorkspace (scopes check)
Job->>Agent: "runInsightsAgent({ serviceAuth: { scopes: ["read:data", "manage:websites"] } })"
Agent->>RPC: create_annotation / update_goal (ALWAYS_ON_TOOLS)
RPC->>Auth: requiredScopesForResource("website", ["update"/"create"])
Auth-->>RPC: requires "manage:websites"
RPC->>Auth: check serviceAuth.scopes includes "manage:websites"
Auth-->>RPC: authorized (after fix)
RPC-->>Agent: success
Agent-->>Job: ParsedInsight[]
Reviews (1): Last reviewed commit: "[superlog] Add manage:websites scope to ..." | Re-trigger Greptile |
Summary
The insights agent (
insights-generate-websitejob) callsannotations.createandgoals.updateas part of its analysis run, but these operations fail withFORBIDDEN: API key missing required scope: manage:websitesbecause the service auth context only grantsread:data.The
annotations.createandgoals.updateRPC procedures both callwithWorkspacewithresource: "website", permissions: ["update"].requiredScopesForResource("website", ["update"])resolves tomanage:websitesviaRESOURCE_SCOPE_OVERRIDESinpackages/api-keys/src/scopes.ts. The insights agent'sserviceAuthwas missing this scope, so every attempt to create an annotation or update a goal is rejected with a 403.The fix adds
"manage:websites"to thescopesarray inrunInsightsAgent'sserviceAuth. This is consistent with the existingALWAYS_ON_TOOLSset which already includescreate_annotation,update_goal,create_goal, andcreate_funnel— all of which requiremanage:websitesto write to website resources.An alternative approach would be to use a user session instead of service auth (passing the
userIdthrough to an impersonated session), but service auth with explicit scopes is the current pattern for background jobs in this codebase and is simpler.Incident on Superlog
Was this PR helpful? Leave feedback — goes straight to the Superlog team.
Summary by cubic
Add the
manage:websitesscope to the insights agent service auth so theinsights-generate-websitejob can create annotations and update goals. This fixes 403 Forbidden errors inannotations.createandgoals.updatecaused by the previousread:data-only scope.Written for commit e77ba87. Summary will update on new commits.