Skip to content

Fix handling of read-only source file cloning#139

Merged
JAORMX merged 2 commits intostacklok:mainfrom
Kensan:fix-ro-file-cloning
Apr 28, 2026
Merged

Fix handling of read-only source file cloning#139
JAORMX merged 2 commits intostacklok:mainfrom
Kensan:fix-ro-file-cloning

Conversation

@Kensan
Copy link
Copy Markdown
Contributor

@Kensan Kensan commented Apr 27, 2026

When invoking bbox in a working directory with read-only file(s), the operation will fail with a "context canceled" error message. These changes fix handling of such files by opening the destination file with write permissions and changing them to match the source file permissions after a successful copy operation.

Additionally, swap the error evaluation order in CreateSnapshot in order to show underlying I/O error messages.

Kensan added 2 commits April 27, 2026 21:24
Otherwise instead of reporting the actual I/O error the following error
message will be shown:

 Error: creating workspace snapshot: walking workspace: context canceled
When a source file has exclusively read permissions (0444), writing to
the file will fail. Instead open the destination file with write
permissions and change them to match src after successful copy.
Copy link
Copy Markdown
Contributor

@JAORMX JAORMX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Confirmed the bug reproduces (FICLONE creates dst at the source's 0o400 mode, fails on tmpfs, and the copyFile fallback can't reopen the read-only dst — EACCES gets masked as "context canceled" via errgroup propagation). The reorder makes the underlying error visible, and opening at 0o600 + post-Chmod is the right fix. macOS path is unaffected (unix.Clonefile preserves perms in-kernel). LGTM.

@JAORMX JAORMX merged commit 54e8d73 into stacklok:main Apr 28, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants