Skip to content

fix: pass artifact paths to rsync via --files-from #1825

Open
Paul-Goulpie wants to merge 2 commits intofirecow:masterfrom
Paul-Goulpie:fix/rsync-artifacts-files-from-arg-max
Open

fix: pass artifact paths to rsync via --files-from #1825
Paul-Goulpie wants to merge 2 commits intofirecow:masterfrom
Paul-Goulpie:fix/rsync-artifacts-files-from-arg-max

Conversation

@Paul-Goulpie
Copy link
Copy Markdown

@Paul-Goulpie Paul-Goulpie commented Apr 5, 2026

fix: pass artifact paths to rsync via --files-from

Problem

When copying artifacts out, each path listed under artifacts.paths
was appended directly as a rsync CLI argument. With a large number of
files (or glob patterns expanding to many files), the total size of
the argument list could exceed ARG_MAX (~2 MB on Linux), causing
rsync to fail silently (swallowed by || true) and producing no
artifacts.

Additionally, glob patterns such as artifact_* were passed
single-quoted to rsync, preventing bash from expanding them — so
rsync received a literal artifact_* and matched nothing.

Solution

  • Collect artifact paths into a temporary file using a bash for
    loop (a shell built-in, not subject to ARG_MAX)
  • The for loop correctly expands glob patterns before writing
    individual resolved paths to the temp file
  • Pass the temp file to rsync via --files-from so the argument
    list remains constant (3 args) regardless of the number of files
  • Remove the temp file after rsync completes

Test

Added tests/test-cases/artifacts-many-paths: creates 9 000 files
with 255-character names (~2.3 MB of paths, exceeding ARG_MAX),
exports them via a glob pattern, and asserts in the consume stage
that all 9 000 files were transferred correctly.


Summary by cubic

Fix artifact export by passing paths to rsync via --files-from to avoid ARG_MAX errors and ensure glob patterns expand correctly. Uses a temp file and a bash for loop to list files safely.

  • Bug Fixes
    • Write expanded artifact paths to a temp file via a bash for loop (not subject to ARG_MAX).
    • Use rsync --files-from to read paths; remove the temp file after.
    • Add an integration test with 9,000 long-named files; assert artifacts are exported and fully consumed under --shell-isolation.

Written for commit d81fcfd. Summary will update on new commits.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/job.ts">

<violation number="1" location="src/job.ts:1430">
P2: Unquoted `echo \$_gcl_f` can split or glob filenames when generating the rsync `--files-from` list, breaking artifact copying for paths with spaces or leading `-` characters. Quote the variable (or use printf) when writing entries.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

- Collect artifact paths into a temp file using a bash for loop
  instead of appending them directly as rsync CLI arguments
- Use rsync --files-from to read paths from the temp file,
  avoiding ARG_MAX (~2 MB) exceeded errors with large artifacts
- The bash for loop (a shell built-in) correctly expands glob
  patterns and is not subject to ARG_MAX constraints
- Remove the temp file after rsync completes
- Add test case with 9000 files of 255-char names (~2.3 MB total
  path size) to verify rsync --files-from handles large artifact
  sets that would exceed ARG_MAX (~2 MB) as CLI arguments
- Assert "exported artifacts" in stdout to catch silent rsync
  failures hidden by || true
- Assert no FAIL in stderr to ensure consume-artifacts receives
  all 9000 files via artifact transfer
- Requires --shell-isolation so artifact transfer is exercised
  rather than the shared cwd being used directly
@Paul-Goulpie Paul-Goulpie force-pushed the fix/rsync-artifacts-files-from-arg-max branch from b24874b to d81fcfd Compare April 5, 2026 07:19
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.

1 participant