@actions/io: `mv(file, dest)` replaces `dest` when it is a symlink to a directory instead of moving into it
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- devtools
Research direction
Read packages/io/src/io.ts and trace how mv checks whether the destination is a directory; compare that check with io.cp and the isDirectory helper’s useStat behavior. Add or update a regression test for moving a file into a symlink to a directory, then confirm the symlink remains and the file appears in the target directory.
Written by the indexing model from the issue text.
Description
Describe the bug
io.mv checks whether dest is a directory with ioUtil.isDirectory(dest), which uses lstat by default. When dest is a symlink pointing to a directory, isDirectory(dest) returns false and dest is treated as an existing file. With the default force: true, the symlink is deleted and the source is renamed to the symlink's path; with force: false, it throws "Destination already exists". By contrast, mv(1) (which @actions/io documents mv as following) and io.cp (which uses stat) move/copy the source into the target directory.
To Reproduce
Run the following with @actions/io:
// repro.mjs
import * as io from '@actions/io'
import fs from 'fs'
fs.mkdirSync('real-dir')
fs.symlinkSync('real-dir', 'link-dir')
fs.writeFileSync('a.txt', 'hello')
await io.mv('a.txt', 'link-dir')
console.log('link-dir is symlink:', fs.lstatSync('link-dir').isSymbolicLink())
console.log('real-dir:', fs.readdirSync('real-dir'))
mkdir demo && cd demo && node ../repro.mjs
Actual output:
link-dir is symlink: false
real-dir: []
(link-dir is now the moved file.)
Expected behavior
Matching mv a.txt link-dir (GNU coreutils 9.1) and io.cp:
link-dir is symlink: true
real-dir: [ 'a.txt' ]
Screenshots
N/A
Desktop (please complete the following information):
- OS: Linux (x86_64)
- Browser: N/A
- Version:
@actions/io3.0.2 (npm latest),actions/toolkitmain0c3a9c3, Node.js v26.13.0
Smartphone (please complete the following information):
- Device: N/A
- OS: N/A
- Browser: N/A
- Version: N/A
Additional context
In packages/io/src/io.ts, mv calls ioUtil.isDirectory(dest), whose useStat parameter defaults to false (lstat). Passing ioUtil.isDirectory(dest, true) would use stat and match io.cp and mv(1).
Credit: https://ucsbplse.github.io/
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- Avg merge
- 15m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from actions/toolkit
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
@actions/exec: `exec(commandLine)` drops `""` arguments and trims trailing spaces of the last argumentPossibly taken @bardrop claimed this 7 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
actions/toolkit#2565 · 1 comment ·
Maintainers usually reply within 1 day
-
@actions/cache: downloadCacheHttpClientConcurrent never stops its progress timer on failure, so the step hangs until the job times outPossibly taken @YodHeVauHe claimed this 46 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
Similar issues
-
db-d1-sqlite: upsert is aliased to updateOne, so payload.kv.set never inserts new keysPossibly taken @pcbeingused333 claimed this today. OpenBug db: d1-sqlite Payload OSS
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
payloadcms/payload#19766 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
device-management-toolkit/sample-web-ui#3711 ·
Maintainers usually reply within 1 day
-
bug impact:low Team: SecuritySolution Team:Defend Workflows v9.6.0
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
elastic/kibana#306401 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
agentes-chat/agentes-chat#927 ·
Maintainers usually reply within 1 day
-
Closing a pinned tab jumps to the Tabs section instead of the next open pinned tabPossibly taken @seenimohamed claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ardia-browser/ardia#2769 ·
Maintainers usually reply within 1 day