Skip to content

Bug: Conversation status transitions (close/reopen/spam + all bulk actions) fail with audit-chain RLS "insert access not allowed" #1972

Closed

Description

@yannickmonney

What happened?

Closing, reopening, marking-as-spam or archiving a conversation from the inbox — both the single-item header action and every bulk action — throws a Convex server error and the conversation's status never changes. Found independently by two QA agents (direct mutation call and via the inbox UI); the mutation rolls back and a reload shows the conversation still in its original lane.

Steps to reproduce

  1. Open /dashboard/{org}/conversations/open with one or more conversations.
  2. From a conversation's More-actions menu choose Close conversation (or select rows and use a bulk action).
  3. Observe the server error; reload — the conversation is still open.

Expected behavior

Closing/reopening/archiving a conversation persists the new status (it leaves the current lane and appears in the target lane after reload) with no server error.

Affected service

Platform (web app)

Version or commit

b4180755d

Browser and OS

Headless Chrome (Playwright) on macOS

Relevant log output / evidence

Uncaught Error: insert access not allowed
  at insert (rowLevelSecurity.js:192)
  at async createAuditLog (convex/audit_logs/helpers.ts:220)
  at async closeConversation (convex/conversations/close_conversation.ts:31)

Root cause. closeConversation/reopenConversation/markConversationAsSpam and the five bulk*Conversations handlers are mutationWithRLS (convex/conversations/mutations.ts:77+). They call AuditLogHelpers.logSuccess(ctx, …) with the RLS-wrapped ctx (close_conversation.ts:31). createAuditLog then writes the per-org auditLogChainGenesis sentinel — ctx.db.insert/ctx.db.patch (audit_logs/helpers.ts:208-224). But the RLS rule for that table is deny-all for every user (lib/rls/helpers/rls_rules.ts:566-570), whose own comment says “writes happen exclusively through internalMutation… the user-facing gate is deny-all.” So any audit write on an RLS ctx is denied and the whole mutation aborts. Conversations arrive via internal mutations (audit bypasses RLS), which is why ingestion works but user-facing status changes do not.

Suggested fix. Emit the audit log off the RLS-wrapped ctx for these user mutations (run createAuditLog via an internalMutation/scheduler, the path the deny-all rule's comment already assumes), or otherwise exempt the audit-chain tables from the user-facing RLS write check for legitimately-emitting mutations.


Filed by an automated manual-QA sweep against a local hermetic stack (commit b4180755d, mode-A mock LLM, headless Chrome). Reproduced live before filing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    automatedbugpriority: highservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions