Skip to content

fix(deploy): accept pending/syncing/degraded provider states as connected#132

Merged
khaliqgant merged 1 commit into
mainfrom
fix/deploy-preflight-accept-syncing-pending-states
May 22, 2026
Merged

fix(deploy): accept pending/syncing/degraded provider states as connected#132
khaliqgant merged 1 commit into
mainfrom
fix/deploy-preflight-accept-syncing-pending-states

Conversation

@khaliqgant

Copy link
Copy Markdown
Member

Summary

Follow-up to #131. The strict preflight introduced there only accepts `status: ready` from the cloud's `deriveProviderState` output, but that function actually emits five states and `ready` is reached only after Nango's initial sync completes. Fresh OAuth grants sit in `pending` (queued) or `syncing` (running) for a few minutes — both real, usable connections — and the preflight rejects them.

Concrete failure mode: user runs `agentworkforce login` + `agentworkforce deploy` (gets prompted for github + slack, completes OAuth, deploy succeeds). Two minutes later they re-deploy — preflight queries `/me/integrations`, sees `status: pending`/`syncing`, prompts OAuth a second time despite the connections being fully real.

Cloud's emitted states

`cloud/packages/web/lib/integrations/provider-status.ts:214` returns one of:

State Meaning Preflight verdict
`ready` Sync complete, writeback healthy ✅ connected
`pending` OAuth done, sync queued ✅ connected (new)
`syncing` Initial sync running ✅ connected (new)
`degraded` Sync complete but writeback lagging/paused ✅ connected (new)
`error` Sync failed or writeback errored ❌ rejected

Personas with declared integrations can use a `pending`/`syncing` connection at runtime — writes go through immediately; sync-backed reads return data once Nango finishes. `error` stays rejected so the user can repair a broken integration via fresh OAuth.

Test plan

  • `pnpm --filter @agentworkforce/deploy test` — 118/118 pass
  • 4 new positive tests, one per accepted non-`ready` state
  • 1 new negative test confirming `error` is still rejected
  • Existing strict tests for `expectedConfigKey` matching, `/me` fallback, orphan-row rejection still pass

🤖 Generated with Claude Code

Cloud's deriveProviderState (provider-status.ts:214) emits one of:
ready | pending | syncing | degraded | error. The preflight matcher
only accepted "ready", which forced users to wait for Nango's initial
sync to complete between OAuth completion and their first usable
deploy — every freshly-connected integration sits in `pending` or
`syncing` for a few minutes and tripped the "not connected" branch.

Concretely the failure mode is: user runs `agentworkforce login`,
deploys (gets prompted for github + slack, completes OAuth, deploy
succeeds because the deploy run itself proceeds past the prompt), then
re-deploys minutes later — preflight queries /me/integrations, sees
status="pending"/"syncing", rejects, prompts OAuth a second time even
though the connections are fully real.

Fix: accept ready | pending | syncing | degraded. Reject only `error`
and missing rows. From a persona's runtime perspective these all
represent a live OAuth grant — writes go through immediately;
sync-backed reads return data once Nango finishes. `error` stays
rejected so users can repair a broken integration via fresh OAuth.

Added test coverage for each of the 4 accepted states + the rejected
error state.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@khaliqgant has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 37 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 409e471c-2a7d-4889-9848-ef762d0d6bcb

📥 Commits

Reviewing files that changed from the base of the PR and between 0fee525 and 464d736.

📒 Files selected for processing (2)
  • packages/deploy/src/connect.test.ts
  • packages/deploy/src/connect.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/deploy-preflight-accept-syncing-pending-states

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

@khaliqgant khaliqgant merged commit 6fc3724 into main May 22, 2026
3 checks passed
@khaliqgant khaliqgant deleted the fix/deploy-preflight-accept-syncing-pending-states branch May 22, 2026 22:28
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