Skip to content

fix(dataverse): harden OAuth connection preflight - #7238

Merged
waleedlatif1 merged 2 commits into
stagingfrom
codex/dynamics-release-review-7224
Aug 28, 2026
Merged

fix(dataverse): harden OAuth connection preflight#7238
waleedlatif1 merged 2 commits into
stagingfrom
codex/dynamics-release-review-7224

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • preserve canonical legacy scopes in generic Dataverse OAuth authorization
  • fail Dataverse reconnects before draft creation when the environment binding cannot be trusted
  • surface invalid workflow environments and Better Auth link failures instead of reporting success

Type of Change

  • Bug fix

Testing

  • 28 targeted tests passing
  • bun run lint:check
  • bun run type-check
  • bun run apps/sim/scripts/check-block-registry.ts origin/staging
  • bun run check:audits

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)

@vercel

vercel Bot commented Aug 28, 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 28, 2026 11:16pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR hardens Dataverse OAuth setup and reconnect preflight while preserving the canonical scopes required by legacy authorization.

  • Supplies canonical Dataverse scopes to generic OAuth link requests.
  • Validates reconnect bindings before creating connection drafts.
  • Surfaces invalid workflow environments and Better Auth link failures.
  • Adds targeted coverage for authorization scopes, reconnect preconditions, invalid environments, and link errors.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/app/api/auth/oauth2/authorize/route.ts Passes provider-specific canonical scopes into generic OAuth account linking while preserving existing draft and callback behavior.
apps/sim/hooks/queries/oauth/microsoft-dataverse-connections.ts Centralizes reconnect preflight checks and converts Better Auth link failures into rejected mutations.
apps/sim/app/workspace/[workspaceId]/integrations/connected/[credentialId]/connected-credential-detail.tsx Runs the centralized Dataverse reconnect assertion before creating a credential draft.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/microsoft-dataverse-policy.ts Explicitly models invalid requested environments in the Dataverse credential policy.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/credential-selector.tsx Displays invalid-environment guidance independently of credential selection and suppresses inappropriate OAuth actions.

Sequence Diagram

sequenceDiagram
  actor User
  participant UI as Dataverse UI
  participant Preflight as Reconnect preflight
  participant Draft as Credential draft API
  participant OAuth as OAuth authorization
  participant BA as Better Auth

  User->>UI: Connect or reconnect Dataverse
  UI->>Preflight: Validate environment binding
  alt Binding cannot be trusted
    Preflight-->>UI: Surface validation error
  else Binding is valid
    Preflight->>Draft: Create connection draft
    Draft-->>UI: Return draft ID
    UI->>OAuth: Start authorization
    OAuth->>BA: Link account with required scopes
    alt Link creation fails
      BA-->>UI: Return surfaced error
    else Link created
      BA-->>User: Redirect to Microsoft consent
    end
  end
Loading

Reviews (2): Last reviewed commit: "fix(dataverse): preserve legacy reconnec..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai 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.

2 issues found across 8 files

Confidence score: 3/5

  • connected-credential-detail.tsx can throw during legacy Dataverse reconnection before reaching the desktop-capable path, blocking users from reconnecting that credential; skip the web-only preflight for legacy bindings while preserving the intended rejection cases.
  • credential-selector.tsx fails to mark a Dynamics workflow for update when an invalid non-empty environment URL exists before credential selection, allowing invalid configuration to persist; decouple the URL validation from the hasOAuthSelection gate.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/credential-selector.tsx">

<violation number="1" location="apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/credential-selector.tsx:216">
P2: When a Dynamics workflow contains an invalid non-empty environment URL before a credential is selected, this condition never makes `needsUpdate` true because the whole expression remains gated by `hasOAuthSelection`; the selector therefore does not surface the invalid environment. Evaluate `hasInvalidEnvironment` outside the credential-selection gate while keeping scope/account updates gated on a selected credential.</violation>
</file>

<file name="apps/sim/app/workspace/[workspaceId]/integrations/connected/[credentialId]/connected-credential-detail.tsx">

<violation number="1" location="apps/sim/app/workspace/[workspaceId]/integrations/connected/[credentialId]/connected-credential-detail.tsx:133">
P2: When a legacy Dataverse credential is reconnected in the desktop app, this preflight throws before reaching the generic desktop-capable branch below. Skip the web-only check for legacy bindings while still rejecting query failures and invalid bindings.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

@waleedlatif1
waleedlatif1 force-pushed the codex/dynamics-release-review-7224 branch from b447a24 to c67bafb Compare August 28, 2026 23:16
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic review

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown

@cubic review

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 44a3e44 into staging Aug 28, 2026
27 checks passed
@waleedlatif1
waleedlatif1 deleted the codex/dynamics-release-review-7224 branch August 28, 2026 23:34
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.

1 participant