Repository navigation
Keep non-ASCII letters and punctuation in ids derived from names - #1605
Merged
Merged
Conversation
slugify replaced every non-word character with a hyphen, so names in other scripts lost their letters and their ids didn't match Lightning's. It now only replaces characters that aren't safe in file names. Names that differ only by case or by space vs hyphen still give the same id. A pull now rejects them, as Lightning's export does, so the resources.yaml writer no longer adds -2 suffixes to channel keys.
The new slug rules change some resources.yaml keys, and merging only matched channels by key, so a channel whose key changed lost its id and was treated as removed. The checkout file now records channel_uuids by key, as it already does for workflows. A merge matches channels by id first, then by key, then by name.
midigofrank
marked this pull request as ready for review
October 29, 2026 15:30
Collaborator
|
@midigofrank can you add a separate changeset for the channels change? We'll keep the work here, I just want it represented in the release notes (and the PR body) |
Collaborator
|
This was sort of done here: #1531 - but I'm going to prefer this PR (and extend it) Also there was a discussion around this when looking at support for apollo OpenFn/lightning#4577 I can't find the thread now - but it was anticipated that some step names would clash (thumbsup/thumbsdown emoji was the example). I'll accept the fixes but I suspect this is the sort of thing that comes out of QA and doesn't impact the real world |
…kit into fix-slugify-unicode
josephjclark
approved these changes
Nov 2, 2026
josephjclark
added a commit
that referenced
this pull request
Nov 3, 2026
* Keep non-ASCII letters and punctuation in ids derived from names (#1605) * Keep non-ASCII letters and punctuation in ids slugify replaced every non-word character with a hyphen, so names in other scripts lost their letters and their ids didn't match Lightning's. It now only replaces characters that aren't safe in file names. Names that differ only by case or by space vs hyphen still give the same id. A pull now rejects them, as Lightning's export does, so the resources.yaml writer no longer adds -2 suffixes to channel keys. * Track channel ids in the checkout file The new slug rules change some resources.yaml keys, and merging only matched channels by key, so a channel whose key changed lost its id and was treated as removed. The checkout file now records channel_uuids by key, as it already does for workflows. A merge matches channels by id first, then by key, then by name. * add changeset for channels change * comments and tests --------- Co-authored-by: Joe Clark <jclark@openfn.org> * Fix pull alias (#1610) * add failing tests * fix * changeset * versions --------- Co-authored-by: Midigo Frank <39288959+midigofrank@users.noreply.github.com>
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.
Short Description
Workflow, step and channel ids now keep non-ASCII letters and punctuation from their names, so they match the ids Lightning uses. Channels are also tracked by their Lightning id, so a change to their keys can't delete them on deploy.
Fixes #1602
Fixes #1603
Background
Until OpenFn/lightning#5106 (September 2026), Lightning only allowed ASCII letters, digits, spaces,
_and-in job and workflow names, andslugifywas written for that. Lightning now accepts any character except control characters, so names like患者確認orEvent-based workflow 1 (rename)reach the CLI. Lightning's own v2 export builds ids by lowercasing the name and replacing spaces with-, and nothing else. This PR follows the same rule.Implementation Details
This PR has two commits, each with its own changeset.
Ids derived from names
slugifyused to turn every non-word character into a hyphen. Names in other scripts lost their letters (患者確認became an empty id), and names with punctuation got ids that didn't match Lightning's (Event-based workflow 1 renameandEvent-based workflow 1 (rename)both becameevent-based-workflow-1-rename). It now trims, NFC-normalizes and lowercases the name, and turns spaces into-as Lightning does. Characters that aren't safe in file names (/ \ : * ? " < > |) and a leading.are also replaced with-. Those are the only cases where our ids differ from Lightning's.The same
slugifyis used for workflow, step, channel and project ids. Project ids for names with punctuation change too. That's harmless, because projects are matched by uuid first.Ids are no longer URL-safe. Nothing puts a local id in a URL: they're only used as file and folder names and as YAML keys.
Some different names still resolve to the same id:
Foo Barandfoo-bar). Lightning's export rejects these too.Q3/Q4andQ3:Q4) or by a leading dot (.fooand-foo). Lightning keeps these characters in its ids, so its export allows these pairs.A pull now fails with an error listing the clashing workflow, step or channel names.
Channels
Channels in
resources.yamlhave no ids, and merge matched them to Lightning's channels by key only. Any remote channel whose key wasn't found locally was sent to Lightning withdelete: true. That caused two problems:slugifychanges some channel keys. A hand-edited key inresources.yamlhas the same effect. Either way, the channel lost its id on the next deploy and was deleted and recreated, which also removes its data in Lightning.My Channelandmy-channel),toResourceChannelswrote the second one under a-2suffix. That only got the pull through. On deploy, both remote channels had the keymy-channel, so merge matched only one of them: localmy-channelmight update the other channel, and localmy-channel-2was created as a new channel.The fix tracks channels the way workflows are tracked:
channel_uuidsby key, as it already does forworkflow_uuids, andfrom-fsreads them back.mergeChannelsmatches by id first, then key, then name. Matching by name covers checkouts written by an older CLI, which have nochannel_uuids.-2suffix is gone. Clashing channel names are rejected on pull like workflows and steps, so a project with channels namedMy Channelandmy-channelthat used to pull will now fail until one of them is renamed.One case can still recreate a channel: the checkout has no
channel_uuids, the channel's name has punctuation, and the name was changed locally before deploying. The first pull with this version writeschannel_uuidsand closes that gap.Known limits
Windows reserved names (
CON,NUL) and trailing dots aren't handled.QA Notes
Flujo de atención (v2.0). The folder and step ids should keep those characters.resources.yamlkeys for those names will change. Channels should keep their ids and should not show up as removed on deploy.resources.yaml, then deploy. The channel should be updated in place, not deleted and recreated.My Flowandmy-flow, then pull. It should fail with an error naming both.AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):
You can read more details in our
Responsible AI Policy