Skip to content

fix(oauth): bind update access to selected credential - #6999

Merged
BillLeoutsakosvl346 merged 6 commits into
stagingfrom
fix/slack-update-access
Aug 24, 2026
Merged

fix(oauth): bind update access to selected credential#6999
BillLeoutsakosvl346 merged 6 commits into
stagingfrom
fix/slack-update-access

Conversation

@BillLeoutsakosvl346

@BillLeoutsakosvl346 BillLeoutsakosvl346 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Bind existing-credential reauthorization to the exact selected OAuth credential before redirecting. This makes the callback use the established draft reconnect path instead of relying on provider account-ID matching, which can leave a legacy Slack credential pointing at its old account after Update access.

The change is provider-agnostic and applies to workflow credential selectors, tool-input credential selectors, and knowledge connectors. Provider-only Copilot reauthorization remains unchanged.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • bun run --cwd apps/sim test 'app/workspace/[workspaceId]/components/connect-oauth-modal/connect-oauth-modal.test.tsx' lib/credentials/draft-processor.test.ts lib/credentials/draft-hooks.test.ts (18 tests passed)
  • bun run --cwd apps/sim type-check
  • Changed-file Biome check
  • Chrome-controlled local app verification with a disposable localhost-only Slack credential whose stored scope was chat:write:
    • Confirmed the Slack block displayed Additional permissions required and Update access.
    • Confirmed the existing Connect Slack permission modal rendered without visual regressions.
    • Confirmed POST /api/credentials/draft created draft 7e70aa5f-afc3-42df-95b4-5ed144dd5748 for workspace 6762b941-0cb8-4787-918d-c8ac76d501b4, provider slack, selected credential ea789bd4-17c9-4a8f-80fd-123456789004, and display name Local incomplete Slack.
    • Confirmed the subsequent POST /api/auth/oauth2/link was attempted. The local run used port 3001 because port 3000 was occupied by another worktree, so Better Auth rejected the local origin before any Slack redirect. The focused modal test separately verifies that the returned draft ID is forwarded into this link call.
    • Removed the disposable workflow, account, credential, draft, and any matching audit rows afterward.

No live Slack OAuth flow was completed, no real grant or credential was modified, and no provider configuration was changed.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

Not applicable: no visual changes are intended. Chrome verification confirmed the existing warning and modal presentation.

@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 24, 2026 7:21pm

Request Review

@cursor

cursor Bot commented Aug 22, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes OAuth reauthorization and credential draft binding across multiple entry points; incorrect wiring could update the wrong credential, but behavior is guarded with fail-closed UI and new tests.

Overview
Update access and Reconnect now tie OAuth reauthorization to the exact credential the user selected, instead of starting a provider-only flow that could match the wrong account on callback (e.g. legacy Slack credentials keeping an old account after scope updates).

ConnectOAuthModal in reauthorize mode accepts optional reconnectTarget (workspace, credential id, display name). When set—and when onConnect is not overriding—it creates a credential draft bound to that credential, then passes the returned draftId into the OAuth link so the callback uses the existing draft reconnect path. Provider-only reauthorization (no target) is unchanged.

Workflow credential selectors, tool-input selectors, and knowledge connector cards pass reconnectTarget, use the stored credential’s provider for the redirect, disable reconnect when the credential cannot be resolved, and close the modal plus clear OAuth return context if the credential vanishes while loading.

Tests cover modal draft ordering/errors, connector UI behavior, and draft processing for Slack reconnect via an exact draft.

Reviewed by Cursor Bugbot for commit fe47b61. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR binds OAuth reauthorization to the exact selected credential through a pending credential draft and fails closed when a knowledge connector’s stored credential cannot be resolved.

  • Adds credential-bound draft creation before OAuth reauthorization.
  • Passes the selected credential’s provider, identity, workspace, and display name from workflow and knowledge credential selectors.
  • Keeps reconnect state stable during credential loading and closes it when the credential is definitively unavailable.
  • Adds focused tests for draft forwarding, provider-specific reconnects, loading transitions, and draft processing.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/components/connect-oauth-modal/connect-oauth-modal.tsx Creates a credential-bound draft before reauthorization and forwards its identifier into the OAuth launch.
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/connectors-section/connectors-section.tsx Resolves the connector’s stored credential, uses its exact provider and identity for reconnect, and fails closed when it cannot be resolved.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/credential-selector.tsx Binds workflow credential reauthorization to the selected credential and closes stale reconnect state after credential resolution.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/tools/credential-selector.tsx Applies the exact-credential reconnect path to tool-input credential selection.
apps/sim/lib/credentials/draft-processor.test.ts Verifies that an exact Slack draft reconnects its bound credential regardless of the returned account identity.

Sequence Diagram

sequenceDiagram
    participant User
    participant Selector as Credential selector
    participant Modal as OAuth modal
    participant Draft as Credential draft API
    participant OAuth as OAuth provider
    participant Callback as OAuth callback
    User->>Selector: Update access
    Selector->>Modal: Reauthorize exact credential
    Modal->>Draft: Create draft with provider and credential ID
    Draft-->>Modal: Return draft ID
    Modal->>OAuth: Launch OAuth with draft ID
    OAuth-->>Callback: Return updated provider account
    Callback->>Draft: Process exact credential draft
    Draft-->>User: Reconnect selected credential
Loading

Reviews (7): Last reviewed commit: "fix(oauth): refresh resolved connector c..." | Re-trigger Greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

Addressed both provider-binding findings in 36fe7d0, added focused regression coverage, and reran the focused suite, Biome, and type-check.

@greptile
@cursor review

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

Addressed the stale OAuth return-context finding in 1014ba6 with focused lifecycle coverage; all 27 focused tests, Biome, and type-check pass.

@greptile
@cursor review

@icecrasher321

Copy link
Copy Markdown
Collaborator

bugbot run

@icecrasher321

Copy link
Copy Markdown
Collaborator

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author
Screen.Recording.2026-08-22.at.6.38.59.PM.mov

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

Addressed the latest Bugbot credential-loading race in 4f1ee9f.

@cursor review
@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator

bugbot run

@icecrasher321

Copy link
Copy Markdown
Collaborator

@greptile

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 fe47b61. Configure here.

@BillLeoutsakosvl346
BillLeoutsakosvl346 merged commit 445ef62 into staging Aug 24, 2026
30 checks passed
@icecrasher321
icecrasher321 deleted the fix/slack-update-access branch August 24, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants