Skip to content

refactor(API): Migrate workflow activate and deactivate to the decorator pattern (no-changelog) - #36928

Draft
uddish wants to merge 5 commits into
masterfrom
api-199-migrate-workflow-activate-and-deactivate-to-the-decorator
Draft

refactor(API): Migrate workflow activate and deactivate to the decorator pattern (no-changelog)#36928
uddish wants to merge 5 commits into
masterfrom
api-199-migrate-workflow-activate-and-deactivate-to-the-decorator

Conversation

@uddish

@uddish uddish commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Moves POST /workflows/{id}/activate and POST /workflows/{id}/deactivate onto WorkflowsPublicController, and deletes their hand-written YAML. Both are deprecated aliases, so each one calls the route it aliases: activate calls publish, deactivate calls unpublish.

Two things the diff raises:

  • ActivateWorkflowPublicDto is PublishWorkflowPublicDto with different field descriptions. /activate documents its body in terms of activation, /publish in terms of publication, so they cannot share one DTO without changing the spec.
  • A 401 from these two routes now carries the Deprecation header, where before it did not. The header is set before authentication runs instead of after. Successful responses are unchanged.

How to test

  • POST /workflows/{id}/activate on a workflow with a trigger. It should return 200 with a Deprecation header.
  • POST /workflows/{id}/deactivate on a published workflow. It should return 200 with a Deprecation header.
  • POST /workflows/{id}/publish and POST /workflows/{id}/unpublish. They should return 200 with no Deprecation header.
  • Open /api/v1/docs. Publish a workflow and Deactivate a workflow should still be listed, struck through.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/API-199

Part of https://linear.app/n8n/issue/API-84

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)

🤖 PR Summary generated by AI

uddish and others added 4 commits August 24, 2026 12:59
…tor pattern

Moves the deprecated `POST /workflows/{id}/activate` and
`POST /workflows/{id}/deactivate` aliases off the legacy
express-openapi-validator handler onto `WorkflowsPublicController`, the first
production use of `@Deprecated`.

Each alias mirrors its own non-deprecated twin rather than the other: activate
takes a body, `workflow:activate`/`workflow:publish` and the 409 publish
blocker, while deactivate takes none of those. Both delegate to the handler
method they alias, as the legacy tuples did by spreading `publishWorkflow`.

`workflows.handler.ts` loses both tuples and the `publishWorkflow` /
`unpublishWorkflow` bodies that existed only to serve them, and
`workflows.id.activate.yml` / `workflows.id.deactivate.yml` are deleted outright.
`workflow-publish-blocked.openapi.test.ts` read the activate YAML off disk, so
it now asserts the generated fragment's inline 409 the way its sibling publish
case already did.

Part of https://linear.app/n8n/issue/API-199

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Generator output from the full build.

`publishWorkflow.generated.yml` shrinks because `WorkflowPublishPublicDto` now
has a second consumer, so the generator hoists its 200 body into
`shared/spec/schemas/workflowPublishPublicDto.generated.yml` and both routes
`$ref` it. That hoist is what broke the bundled spec in #36450, when a
`nullable` with no sibling `type` compiled inside a path but not inside a
component. It is safe here: #35835 gave every field a real type, and the new
component carries no bare `nullable`.

Part of https://linear.app/n8n/issue/API-199

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`/activate` reused `PublishWorkflowPublicDto`, which describes its three fields
in terms of publication. The route's hand-written YAML described them in terms
of activation, so reusing the DTO changed three descriptions in the published
spec on a route this PR only moves.

`ActivateWorkflowPublicDto` restores that wording. It sits beside the publish
schema rather than in its own file so the divergence is visible, and carries a
note against collapsing the two.

Part of https://linear.app/n8n/issue/API-199

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…kflow-activate-and-deactivate-to-the-decorator
@n8n-assistant

n8n-assistant Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

PR review overview

Based on ownership of the 13 changed files in this PR:

Ownership Files owned Share Source code Test files Misc
@n8n-io/ligo 11 85% +665 / -650 +15 / -16 +0 / -0
@n8n-io/catalysts 2 15% +19 / -0 +0 / -0 +0 / -0
Total 13 100% +684 / -650 +15 / -16 +0 / -0

@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 1.62kB (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
editor-ui-esm 63.05MB 1.62kB (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: editor-ui-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/src-*.js 2.37kB 3.34MB 0.07%
assets/ParameterInputList-*.js 300 bytes 1.47MB 0.02%
assets/workflows.store-*.js 2.34kB 825.0kB 0.28%
assets/markdown-*.js -3.64kB 263.31kB -1.36%
assets/builder.store-*.js 30 bytes 111.75kB 0.03%
assets/CanvasRunWorkflowButton-*.js 222 bytes 97.09kB 0.23%

@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@n8n-assistant n8n-assistant Bot added n8n team Authored by the n8n team core Enhancement outside /nodes-base and /editor-ui labels Aug 24, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant