Repository navigation
Conversation
…ed workflows --cleanup-orphans only ever handled files missing an embedded workflow ID; a file whose workflow had since been deleted in n8n was never touched despite the flag being documented as deleting "local files without matching remote workflow." Track every remote workflow ID seen during the sync pass and delete local files whose embedded ID isn't among them (respecting --ids scoping and leaving archived/filtered-out workflows alone). --cleanup-subfiles independently cleans up any _subfiles/ directory whose workflow ID has no matching local file, whether that's because --cleanup-orphans just removed it or the file was already gone (manual deletion, or an older n8n-cli that didn't clean up after itself). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
jspaans91
marked this pull request as ready for review
September 19, 2026 10:44
jspaans91
marked this pull request as draft
September 19, 2026 10:45
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.
Summary
--cleanup-orphanswas documented as deleting "local files without matching remote workflow", but only ever handled files with no embedded workflow ID. A local file whose workflow had since been deleted in n8n (i.e. it has an ID, but that ID no longer exists remotely) was never touched. Now every remote workflow ID seen during the sync pass is tracked, and any local file whose embedded ID isn't in that set gets deleted (respecting--idsscoping, and leaving archived/tag-filtered-out workflows alone since they still exist remotely).--cleanup-subfilesnow independently removes any_subfiles/directory whose encoded workflow ID has no matching local workflow file — whether that's because--cleanup-orphansjust deleted it, or the file was already gone (manual deletion, or an oldern8n-clithat didn't clean up after itself). This is gated purely on--cleanup-subfiles, not on--cleanup-orphans, matching how the flag is documented.Test plan
tests/importer/cleanup-orphans.test.tscovering: stale file deletion, keeping files that still exist remotely, keeping archived (not deleted) workflows, dry-run reporting only,--idsscoping,_subfilesdirectory cleanup (both tied to a just-deleted workflow and pre-existing orphaned directories with no local file at all), and that_subfilescleanup requires--cleanup-subfilesindependently of--cleanup-orphans.bun test— full suite passes (1997 tests)bunx tsc --noEmit— cleanbun run lint— clean on changed files