Skip to content

project: pull crashes when step names with no ASCII characters slugify to the same empty id #1603

Open

Description

@midigofrank

Related to #1602 (workflow names slugifying to the same id). This issue is the same problem at the step level.

Problem

openfn project pull fails with:

✘ Error: Edge references unknown target "5440d66f-d77d-4abe-8bc1-749c15850f3b". seems a node's id changed without edges connecting to it being updated.
    at generateHash
    at Workflow.getVersionHash
    at Workflow.canMergeInto
    at _Project.canMergeInto
    at hasUntrackedChanges

Seen in the GitHub sync action (openfn/cli-pull-action@v2) against a staging project. The workflows Flujo de atención al ciudadano and Q3/Q4 "Data-Sync" Workflow (v2.0) … each contain two steps named 患者確認 and فحص المريض.

Cause

  • On pull, from-app-state.ts sets each step id to slugify(step.name).
  • slugify replaces \W, which matches every character outside [A-Za-z0-9_]. A name with no ASCII characters becomes "", and accented names lose letters (atención → atenci-n).
  • Both steps end up with id: '', and nothing checks for duplicate ids.
  • In mapWorkflow, both the step-id→uuid lookup and wfState.jobs use the step id as the key. The two steps overwrite each other, and because one map follows file order and the other is sorted by name, a different step wins in each. An edge then references a uuid that isn't in jobs, and generateHash throws.

The first pull of such a project doesn't crash, because it doesn't hash the tracked project, but it writes both steps' expressions to the same workflows/<wf>/.js, so one step's code is lost. The next pull loads the tracked project in hasUntrackedChanges and crashes.

Repro

Create a workflow in Lightning with two steps named 患者確認 and فحص المريض, then run openfn project pull twice.

Suggested fix

Workaround

Rename the steps so that each name contains at least one ASCII letter or digit.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

  • Status
    New Issues

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions