Repository navigation
feat(api): workflow trigger health and enablement through the v2 API - #9853
Merged
Merged
Conversation
GET /api/v2/workflows/{workflowId}/triggers lists every schedule, polling,
internal-event, and webhook trigger the live deployment serves, disabled
ones included, with failure counts. PATCH .../triggers/{blockId} enables or
disables one without redeploying: enabling resets the failure counters,
re-arms a schedule's next run, and clears polling backoff; a schedule with
no future run is a 409. Liveness is the active deployment version plus an
active or legacy registration, enforced inside one conditional UPDATE, so
a candidate, retired, or older-version row is never revived.
Adds workflows.triggers.read / workflows.triggers.set_enabled, the
WEBHOOK_UPDATED audit action, and the CLI commands
`workflows triggers list|update`.
… the trigger use case PUT /api/schedules/[id] and PATCH /api/webhooks/[id] now call setWorkflowTriggerEnabled, which owns authorization, the workflow lock, the triggers.webhook gate on re-enabling, and audit. Both keep their response shapes. The id must name the live deployment's row, so these routes can no longer revive a candidate, retired, or older-version registration, and the webhook route no longer writes an arbitrary failedCount (failedCount: 0 is still accepted and ignored). Webhook re-enable and disable are now audited. Removes the mock-based route tests the integration suite replaces.
…ock, keep legacy route behavior Live rows now use the delivery and editor deployment test (active version, or versionless deploy with no version id) and no longer filter on registration status, so the editor never shows a row the legacy toggle rejects. A block target switches all of its live rows in one transaction; a row id switches only that row. Disabling a completed schedule moves it to disabled again, a cron with no future run is a 400 with the legacy message, and same-workspace role denials keep their legacy 403 bodies.
… atomic poll auto-disable The v2 list and block target read schedules with the dispatcher's own predicate, so a versionless schedule that never fires is not reported; the legacy row-id route keeps it for the editor. Enabling clears poll backoff only on polling rows with an object config. An unknown schedule status reads as active instead of failing the list. markWebhookFailed increments and auto-disables in one statement, so a concurrent enable is never switched off by a decision made on the old count. Documents that a disable lasts until the next deploy or activation, and that workspace keys are not governed by the webhook capability.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
[Medium impact] The PR appears safe to merge; no new blocking issues remain. SummaryAdds v2 endpoints and CLI commands to inspect trigger health and enable or disable triggers without redeploying.
|
…TCH, switch all or nothing The v2 list and block target require the active version of a deployed workflow for both tables, since webhook processing refuses a versionless or undeployed row; the legacy row-id routes keep the editor's view. PATCH /api/webhooks/[id] admits a workflow run's executor delegation again, and setTriggerEnabled admits the executor service. A multi-row switch rolls back entirely when any row was retired or switched concurrently, so a conflict commits nothing. Adds the two new CLI fences to the docs content baseline.
Collaborator
Author
Collaborator
Author
|
@cubic-dev-ai review this PR |
Contributor
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 34 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/v2/workflows/{workflowId}/triggers: every trigger the live deployment serves (schedules, polling, internal event, and push webhook triggers) with kind, enabled, status, failure count, last failure, and next/last run plus cron for schedulesPATCH /api/v2/workflows/{workflowId}/triggers/{blockId}with{ enabled }: enabling resets failure counters, re-armsnextRunAt, and clears polling backoff; disabling stops Sim accepting the trigger without tearing down the provider registration. A disable lasts until the next deploy, the same way a redeploy already clears an auto-disabled triggerwebhook.updatedaudit entry/deployment's view of the world (it now shows up in/triggersas disabled), and makes polling auto-disable a single conditional update so an enable can't be switched straight back offtriggers.webhookpermission-group gating on enable is preserved; CLIworkflows triggers list|update; regenerated OpenAPI, CLI, MCP operations, and route tableType of Change
Testing
apps/sim/lib/workflows/application/triggers.integration.ts(14 passing) against PostgreSQL: live-row listing, write-time liveness refusal, counter/backoff reset, scalar provider configs, versionless schedules, multi-row blocks, cron validation, lock, role and tenant boundaries, capability gate, no-op audit, poll auto-disable threshold; reverting the liveness predicate, capability gate, no-op detection, counter reset, dispatcher predicate, and config guard each turns its test redoperations.test.ts,list-pagination.test.ts,copilot-route-inventory.test.tstscon apps/sim;check:openapi,cli-api,cli-docs,mcp-operations,v2-route-table,route-verbs,permission-group-enforcement,capability-subject,principal-kind-parity,api-validation:strict,source-conventions,test-patterns,boundaries; biomeChecklist
test-auditauthoring gate)