Repository navigation
fix(drains): a manual reply or voice drain reads only the caller's tenant - #644
Open
privatejoel wants to merge 1 commit into
Open
privatejoel wants to merge 1 commit into
privatejoel wants to merge 1 commit into
Conversation
…nant The manual path of /api/agents/handle_replies and /api/voice/process_actions called drainOnce(svc) on the service role with no tenant filter. An approver in one tenant processed the inbound_emails and voice_call_actions rows of every tenant. drainOnce now takes an optional tenant id. The manual path passes ctx.tenantId. The cron path passes none and still drains all tenants. This follows inbound/process_messages.js and inbound/email/draft_orders.js. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a cross-tenant defect in two manual drain endpoints. The SO agent infrastructure audit plan lists it as D-1 (docs/SO_AGENT_INFRA_AUDIT_PLAN.md, section 8.1).
POST /api/agents/handle_repliesandPOST /api/voice/process_actionsrun on the service role. The service role bypasses RLS.drainOnce(svc)with no tenant filter. An approver in one tenant processed theinbound_emailsrows and thevoice_call_actionsrows of every tenant.drainOncetakes an optional tenant id. The manual path passesctx.tenantId. The cron path (BearerCRON_SECRET, fromsrc/api/cron/tick.js) passes no tenant id. It still drains all tenants.process_actions.jspasses the tenant id todrainQueue, which already supports it.handle_replies.jsadds.eq("tenant_id", tenantId)to its own read when a tenant id is set.src/api/inbound/process_messages.jsandsrc/api/inbound/email/draft_orders.js.Deploy notes
Tests
src/v3-app/api-agents-handle-replies-tenant-scope.test.js(new, 2 tests).src/v3-app/api-voice-process-actions-tenant-scope.test.js(new, 2 tests).npm run checkpasses.Not covered
requirePermission. This PR does not change them:src/api/quotes/expire.js:75src/api/inbound/email/persist_attachments.js:128src/api/inbound/email/parse.js:148src/api/cron/tally-reconcile.js:90src/api/cron/drift-meter.js:156(requiresadmin)src/api/cron/drift-report.js:270tenant_id) did not change. They were correct before, because they act only on rows the read returned.🤖 Generated with Claude Code