Skip to content

fix(cli): preserve swizzle write failures on minimum Node - #11186

Merged
astracat-bot[bot] merged 1 commit into
mainfrom
codebunny/fix/fix-cli-preserve-swizzle-write-failures-on-minimum-node-616d7f
Nov 11, 2026
Merged

astracat-bot[bot] merged 1 commit into
mainfrom
codebunny/fix/fix-cli-preserve-swizzle-write-failures-on-minimum-node-616d7f

Conversation

@astracat-bot

@astracat-bot astracat-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

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.

See also #6840.

@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 11, 2026 8:22am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 11, 2026
@astracat-bot

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 11, 2026, 10:29 AM UTC

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 2fe71ac

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 3.75 MB packed (+2 B); no new dependencies.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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.

Automated review (maintainer link)

@astracat-bot
astracat-bot Bot merged commit d038e89 into main Nov 11, 2026
66 checks passed
@cixzhang cixzhang mentioned this pull request Nov 11, 2026
4 tasks done
@github-actions
github-actions Bot deleted the codebunny/fix/fix-cli-preserve-swizzle-write-failures-on-minimum-node-616d7f branch November 12, 2026 06:06

This branch was successfully deployed

1 active deployment
Preview — 2fe71ac6 Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants