Skip to content

improvement(deployments): bugfixes for run-block, airtable + external sub management#5680

Open
icecrasher321 wants to merge 6 commits into
stagingfrom
improvement/deployment-bugs
Open

improvement(deployments): bugfixes for run-block, airtable + external sub management#5680
icecrasher321 wants to merge 6 commits into
stagingfrom
improvement/deployment-bugs

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Make deployment status truthful end-to-end: deployments now move through an explicit state machine (preparing → activating → active / failed / superseded) backed by an outbox with inline-first execution, so a version is only reported live once its webhooks, schedules, and external subscriptions actually exist. Webhook registration is rebuilt on stable, generation-fenced rows with create-before-delete cutover — a failed deploy can no longer take down the currently live version, leave ghost registrations that wedge future deploys, or silently swallow provider errors (now surfaced in the deploy modal, versions list, and API responses).

Type of Change

  • Bug fix

Testing

Tested manually

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 Jul 15, 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 Jul 15, 2026 3:11am

Request Review

…ment-bugs

# Conflicts:
#	apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/deploy-modal.tsx
@icecrasher321 icecrasher321 marked this pull request as ready for review July 15, 2026 00:22
@cursor

cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Changes cut across deployment cutover, webhook registration/delivery, and background execution admission—areas where races or stale pins directly affect live traffic and multi-tenant isolation.

Overview
Deployment APIs, tools, and the deploy modal now treat isDeployed as “an active version snapshot exists” and expose activeDeployment plus latestDeploymentAttempt (preparing / activating / active / failed) instead of implying cutover finished on HTTP success. Chat updates and deploy/redeploy flows block until the attempt is active (409 while still preparing); the UI polls deployment info and version rows and shows pending/failed badges. Route-level PostHog deploy events are removed in favor of outbox-side effects.

Webhook and trigger execution gains generation-fenced stable registration (prepareStableTriggerWebhooksForDeploy), atomic path claims for cross-tenant collision resolution, a shared deliverable row predicate, and deploymentVersionId (plus schedule deploymentOperationId) carried into queued webhook/schedule/MCP runs so work pins the admitted version or skips when undeployed.

Smaller fixes: Airtable typecast on all write operations; condition else branches matched case-insensitively via shared helper; outbox handlers get an abort signal and safer persisted errors; workspace-fork rollback reactivation uses the async activation prep path.

Reviewed by Cursor Bugbot for commit 341b7e3. Configure here.

Comment thread apps/sim/app/api/workflows/[id]/deploy/route.ts Outdated
Comment thread apps/sim/background/webhook-execution.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

Comment thread apps/sim/app/api/chat/manage/[id]/route.ts
@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes deployment status follow the real deployment lifecycle. The main changes are:

  • Operation-backed deploy preparation and activation.
  • Generation-fenced webhook registration and cleanup.
  • Pinned MCP execution against deployment snapshots.
  • Updated deployment API responses and UI status states.
  • Airtable typecast support for create and update tools.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
apps/sim/lib/webhooks/deploy.ts Adds stable webhook preparation and version-scoped cleanup for deployment operations.
apps/sim/lib/workflows/deployment-outbox.ts Adds deployment preparation, readiness checkpoints, activation, cleanup, and post-activation side effects.
apps/sim/lib/workflows/persistence/deployment-operations.ts Adds deployment operation generation, status transitions, activation guards, and superseding behavior.
apps/sim/app/api/mcp/serve/[serverId]/route.ts Pins MCP tool execution requests to the active deployment version at call time.
apps/sim/app/api/workflows/[id]/execute/route.ts Restricts deployment snapshot execution to the internal MCP bridge path.

Reviews (2): Last reviewed commit: "address comments" | Re-trigger Greptile

Comment thread apps/sim/lib/workflows/persistence/deployment-operations.ts
Comment thread apps/sim/lib/workflows/deployment-outbox.ts
Comment thread apps/sim/lib/workflows/deployment-outbox.ts
Comment thread apps/sim/app/api/mcp/serve/[serverId]/route.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@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.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 341b7e3. Configure here.


if (!prepared.success) {
throw new Error(prepared.error)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Idempotent reactivate skips failed ops

High Severity

prepareWorkflowVersionActivation treats any idempotent hit as success without checking operation status or calling onPrepareTransaction. A retry that reuses a failed, stuck preparing, or dead-lettered attempt restores the draft, returns success with no outboxEventId, and never re-enqueues cutover, so fork rollback can report restored while the version never goes live.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 341b7e3. Configure here.

eq(workflowDeploymentVersion.workflowId, workflow.id),
eq(workflowDeploymentVersion.isActive, true)
)
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

MCP still trusts isDeployed flag

Medium Severity

This change joins the active workflowDeploymentVersion to pin execution, but still admits MCP calls with workflow.isDeployed. The same PR’s deploy GET path already treats an active version snapshot as the source of truth because the legacy flag can disagree. Copilot check_deployment_status also reports isDeployed from the flag while attaching activeDeployment from the summary, so callers can see contradictory live state.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 341b7e3. Configure here.

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