actions / actions/toolkit

`cp()` silently returns when attempting to copy a non-existent file if the would-be destination already exists

Open
#856 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
The cp() function of @actions/io silently returns when attempting to copy a non-existent file if the would-be destination already exists. In other words, it provides no indication of anything wrong. This appears to be due to how the function is written somewhat backwards; instead of validating source then dest, it flows from dest to source while allowing early termination to occur if dest already exists.

Expected behavior
The function should indicate if source does not exist. The /bin/cp of yore exits with a failure code when the source file/directory does not exist. The function should similarly handle the case as an error.

Additional context
https://github.com/actions/toolkit/blob/45647689407e7fb224e06d066dde6aefa67a365f/packages/io/src/io.ts#L46-L49

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked packages/io/src/io.ts lines 46-49 and trace how cp() handles the destination before validating the source. Reproduce the case with a missing source and an existing destination; done means the operation reports an error instead of silently returning, consistent with the expected /bin/cp behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.