Skip to content

Send deleted workflows to Lightning on v1 deploy - #1611

Open
midigofrank wants to merge 1 commit into
mainfrom
fix/deploy-send-deleted-workflows
Open

midigofrank wants to merge 1 commit into
mainfrom
fix/deploy-send-deleted-workflows

Conversation

@midigofrank

Copy link
Copy Markdown
Contributor

Short Description

Removing a workflow from a v1 spec and running openfn deploy fails with a 500. The CLI marks the workflow { id, delete: true } but then drops it from the payload, so Lightning never receives the delete. This sends it.

Follow-up to #1457, which added the { id, delete: true } marking and the filter in toProjectPayload (released in @openfn/cli@1.38.1, which Lightning v2.17.0 bundles).

Implementation Details

  • mergeSpecIntoState marks a workflow that's in state but not in the spec as { id, delete: true }.
  • toProjectPayload then filtered those out, so the document sent to Lightning omitted an existing workflow.
  • Lightning's provisioner casts :workflows with on_replace: :raise. A missing workflow raises you are attempting to change relation :workflows of Lightning.Projects.Project but the :on_replace option of this relation is set to :raise, which comes back as a 500.
  • Lightning soft-deletes a workflow sent as { id, delete: true } (renamed <name>_del, deleted_at set). The CLI now sends that.

The #1457 test only covered mergeSpecIntoState. The new test covers the payload, and fails without this fix.

The as any is there because ProjectPayload['workflows'] requires name/jobs/etc. Widening it to a union breaks getStateFromProjectPayload, so I kept the cast local.

QA Notes

Checked end to end against Lightning main: I added a test to test/integration/cli_deploy_test.exs (not committed there) that pulls the canonical project, deploys the update fixture without workflow-2 and asserts it's soft-deleted.

  • Bundled CLI as shipped: the deploy fails with Internal Server Error.
  • Same one-line change patched into the bundled CLI: all 7 tests in that file pass.

To reproduce: pull a project, remove a workflow from project.yaml, run openfn deploy.

AI Usage

  • I have used Claude Code
  • I have used another model
  • I have not used AI

🤖 Generated with Claude Code

toProjectPayload filtered out workflows that mergeSpecIntoState had
marked { id, delete: true }, so the payload omitted them. Lightning's
provisioner casts workflows with on_replace: :raise, so a document
missing an existing workflow raised and returned a 500 instead of
soft-deleting it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-project-automation github-project-automation Bot moved this to New Issues in Core Dec 2, 2026
@josephjclark

Copy link
Copy Markdown
Collaborator

Just seen this @midigofrank - I'll try and get to it this afternoon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

2 participants