Skip to content

openfn project deploy: new workflows not deployed when using onlyUpdated merge #1272

@elias-ba

Description

@elias-ba

Context

Hi @josephjclark! I was using openfn project deploy (CLI v1.28.0) to migrate workflows from app.openfn.org to a self-hosted instance (openfn.kwunga.org) and ran into something I wanted to flag — not sure if it's a bug or intentional behavior.

What I was trying to do

  1. Pulled a project (5 workflows) from app.openfn.org using openfn project pull <uuid>
  2. Removed all workflows except WF 1 from the local workflows/ directory (I only wanted to deploy WF 1 first)
  3. Deployed to openfn.kwunga.org using openfn project deploy --new — this worked fine and created the project with WF 1
  4. Later, WF 2 and WF 3 were ready to be deployed too. So I re-pulled the full project from app.openfn.org (which brought all 5 workflows back), then deleted the ones I didn't need (keeping only wf-2 and wf-3)
  5. But deploying without wf-1 locally would remove it from kwunga, so I pulled from kwunga (openfn project pull <kwunga-uuid> -f) to get wf-1 back locally
  6. At this point I had all 3 workflows locally: wf-1 (from kwunga), wf-2 and wf-3 (from app)
  7. Ran openfn project deploy (without --new, since the project already exists on kwunga)

What happened

The CLI output said:

♦ Workflows added:
♦   - wf-2-sidainfo-lab-requests-to-ibipimo
♦   - wf-3-retrieves-ibipimo-viral-load-results

ℹ Remote project has not diverged from local project - it is safe to deploy 🎉
ℹ Merging changes into remote project
ℹ Sending project to app...
✔ Updated project at https://openfn.kwunga.org

But when checking the project on openfn.kwunga.org, only WF 1 was there — WF 2 and WF 3 were never actually deployed despite the success message.

What I found

In the deploy handler (syncProjects), the merge is called with onlyUpdated: true:

const merged = Project.merge(localProject, remoteProject, {
    mode: "replace",
    force: true,
    onlyUpdated: true
});

This triggers find_changed_workflows_default(source) in @openfn/project, which filters source workflows:

var find_changed_workflows_default = (project) => {
  const base = project.cli.forked_from ?? project.workflows.reduce((obj, wf) => {
    if (wf.history.length) {
      obj[wf.id] = wf.history.at(-1);
    }
    return obj;
  }, {});
  const changed = [];
  for (const wf of project.workflows) {
    if (wf.id in base) {
      const hash = generateHash(wf);
      if (hash !== base[wf.id]) {
        changed.push(wf);
      }
    }
    // New workflows (not in base/forked_from) are never added to changed[]
  }
  return changed;
};

The issue is that new workflows — ones that don't have an entry in forked_from — are silently excluded from the changed array. They're never included in sourceWorkflows, so they never make it into the merged project that gets sent to the server.

Meanwhile, the diff() function (used for reporting) does correctly detect them as "added", which is why the CLI prints "Workflows added" even though they're ultimately dropped by the merge.

Question

Is this intentional? I wasn't sure if onlyUpdated is meant to exclude brand-new workflows or if new workflows should be treated as changes too.

If it's intentional, is there a recommended way to add new workflows to an existing project via openfn project deploy?

Thanks! 🙏

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions