You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(cli): preserve swizzle write failures on minimum Node - #11186
validation: ran pnpm test packages/cli/clients/cli/commands/swizzle.routing.test.mjs packages/cli/api/swizzle/copy/copy.test.mjs --project node on Node 22.13.0 and Node 24.22.1: 55/55 tests passed on each; targeted ESLint, pnpm check:changesets, and pnpm review:pre passed (zero review findings).
User impact
astryx swizzle Button --output notes.txt --json reports ERR_UNKNOWN rather than ERR_WRITE_FAILED when notes.txt is an existing file on the minimum supported Node version. Automation loses the stable write-failure code and the error exposes a cleanup path instead of the attempted write.
Cause and smallest restoration
Creating the component directory fails with ENOTDIR. Rollback then removes the nonexistent notes.txt/Button directory. On Node 22.13.0, fs.rmSync(..., {recursive: true, force: true}) also throws ENOTDIR, masking the original error before writeFailed runs.
Check that the output directory exists before this fallback cleanup. Keep the write, rollback, overwrite, and path-safety behavior unchanged. Strengthen the existing regression test to check the attempted write's relative path, the no-write outcome, absence of the absolute project path, and preservation of the original file. Include a patch Changeset.
Expected behavior and authority
architecture:cli-surface INV3 preserves stable error-code meanings, and spec:AST-042 FR1–FR2 require API/JSON parity and mutation-sensitive coverage of error codes. The existing writeFailed helper and regression test define ERR_WRITE_FAILED for a path component that is not a directory. No new API or component behavior.
Evidence
Failing workflow: cli-minimum-node.yml, run 42979448837, job 130386201266, Node 22.13.0.
Before: the original assertion failed in 2/2 runs at 63bbda14b3d6ab8085b4ca791fe1c19b8fa25162, 2/2 runs at main 410f9b6276f74235ebf9f2ba7614ad095002378c, and again after refreshing main to 29f6996bf7d8e46576b544873a4a2312bc70ec96.
After: the routing and copy suites passed all 55 tests on Node 22.13.0 and Node 24.22.1, including successful copies, overwrite refusal, symlink safety, and cleanup after a later shared-module write failure. Revalidated all 55 tests on Node 22.13.0 after applying the patch to the refreshed main commit.
Failing test covered: 9fa8ced0087c1e65b166872976dbfbcc47523479163de325a5168cb078e7be4b — packages/cli/clients/cli/commands/swizzle.routing.test.mjs › swizzle — the astryx-swizzle.json marker › reports a write failure when the output path is a file.
The reason will be displayed to describe this comment to others. Learn more.
Approved. On Node 22.13, the CLI's lowest supported version, fs.rmSync(path, {recursive: true, force: true}) throws ENOTDIR for a path below a regular file, so the rollback's cleanup replaced the original write error and astryx swizzle reported ERR_UNKNOWN. Guarding that cleanup with fs.existsSync(outputDir) lets ERR_WRITE_FAILED and its project-relative message through, matching Node 24. The strengthened test fails against the previous code on Node 22.13 and passes with this change on Node 22.13 and 24, and CI on this head has passed.
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
CLA SignedThis label is managed by the Meta Open Source bot.
0 participants
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.
validation: ran
pnpm test packages/cli/clients/cli/commands/swizzle.routing.test.mjs packages/cli/api/swizzle/copy/copy.test.mjs --project nodeon Node 22.13.0 and Node 24.22.1: 55/55 tests passed on each; targeted ESLint,pnpm check:changesets, andpnpm review:prepassed (zero review findings).User impact
astryx swizzle Button --output notes.txt --jsonreportsERR_UNKNOWNrather thanERR_WRITE_FAILEDwhennotes.txtis an existing file on the minimum supported Node version. Automation loses the stable write-failure code and the error exposes a cleanup path instead of the attempted write.Cause and smallest restoration
Creating the component directory fails with
ENOTDIR. Rollback then removes the nonexistentnotes.txt/Buttondirectory. On Node 22.13.0,fs.rmSync(..., {recursive: true, force: true})also throwsENOTDIR, masking the original error beforewriteFailedruns.Check that the output directory exists before this fallback cleanup. Keep the write, rollback, overwrite, and path-safety behavior unchanged. Strengthen the existing regression test to check the attempted write's relative path, the no-write outcome, absence of the absolute project path, and preservation of the original file. Include a patch Changeset.
Expected behavior and authority
architecture:cli-surfaceINV3 preserves stable error-code meanings, andspec:AST-042FR1–FR2 require API/JSON parity and mutation-sensitive coverage of error codes. The existingwriteFailedhelper and regression test defineERR_WRITE_FAILEDfor a path component that is not a directory. No new API or component behavior.Evidence
cli-minimum-node.yml, run 42979448837, job 130386201266, Node 22.13.0.63bbda14b3d6ab8085b4ca791fe1c19b8fa25162, 2/2 runs at main410f9b6276f74235ebf9f2ba7614ad095002378c, and again after refreshing main to29f6996bf7d8e46576b544873a4a2312bc70ec96.Failing test covered:
9fa8ced0087c1e65b166872976dbfbcc47523479163de325a5168cb078e7be4b—packages/cli/clients/cli/commands/swizzle.routing.test.mjs › swizzle — the astryx-swizzle.json marker › reports a write failure when the output path is a file.See also #6840.