fix(credentials): clear stored refs on credential delete to prevent silent cascade orphaning#4418
Conversation
…ilent cascade orphaning
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Updates the OAuth disconnect route and the credential DELETE API (plus the Copilot manage-credential delete tool) to use Adds audit coverage for the OAuth credential lifecycle by recording Reviewed by Cursor Bugbot for commit cb1efeb. Configure here. |
Greptile SummaryThis PR centralizes credential deletion into a new Confidence Score: 5/5Safe to merge — all findings are P2 (performance/observability) with no correctness or security defects. No P0 or P1 issues found. The deletion logic is idempotent, authorization is verified at every call site before deleteCredential is invoked, and the recursive walker is thoroughly unit-tested. The two P2 comments are minor performance and audit-completeness suggestions. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant C as Caller (disconnect / DELETE / copilot)
participant D as deleteCredential()
participant DB as Database
C->>+D: deleteCredential({ credentialId, actorId, reason })
D->>DB: SELECT credential WHERE id = credentialId
DB-->>D: row (workspaceId, type, displayName, ...)
D->>+DB: Promise.all clearCredentialRefs(credentialId, workspaceId)
Note over DB: 5 parallel passes
DB-->>-D: workflow_blocks, deployment_versions, paused_executions, checkpoints, knowledge_connectors updated
D->>DB: DELETE credential WHERE id = credentialId
DB-->>D: ok
D--)C: recordAudit(CREDENTIAL_DELETED) [fire-and-forget]
D-->>-C: void
Reviews (2): Last reviewed commit: "improvement(credentials): parallelize in..." | Re-trigger Greptile |
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit cb1efeb. Configure here.
Summary
lib/credentials/deletion.ts— clears stored refs acrossworkflow_blocks, deployment versions, paused executions, checkpoints, and knowledge connectors before deleting the rowCREDENTIAL_CREATED/CREDENTIAL_RECONNECTEDaudit actions for full credential lifecycle traceabilityCREDENTIAL_SUBBLOCK_IDSto includemanualCredential(latent migration gap)Type of Change
Testing
Tested manually. Added unit tests for the recursive walker covering subBlock, tool params, deployment-style, and checkpoint shapes.
Checklist