Skip to content

fix: repair s3:// input URI and expand ${LOCAL_DIR} in stage-in (#41) - #42

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/41-s3-uri-and-localdir-expansion
Jun 13, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/41-s3-uri-and-localdir-expansion

Conversation

@scttfrdmn

Copy link
Copy Markdown
Collaborator

Closes #41.

The filer (on 0.2.10, after #39's permission fix) read the actual generated staging script off the head node and found the declared-input copies from #37/#38 were malformed — so inputs were never landed, silently.

Two bugs in buildInputStaging's emitted commands

Bug 1 — s3:/// (empty authority). nf-amazon's S3 Path renders toUri().toString() as s3:///bucket/key (three slashes) — the bucket lands in the path, not the authority, so aws s3 cp parses an empty bucket and fails. New normalizeS3Uri() collapses a leading s3:/// → s3://.

Bug 2 — unexpanded ${LOCAL_DIR} in the dest. shellQuote() wrapped the whole dest in single quotes, so the literal ${LOCAL_DIR} was passed to aws verbatim — even with bug 1 fixed, the file would land in a directory literally named ${LOCAL_DIR}. Now ${LOCAL_DIR}/ is kept outside the single quotes (only the stage name is quoted), same as WORKDIR_S3/AWS_REGION. Applies to both the mkdir -p and the aws s3 cp.

Plus: fail loud

The script runs set -uo pipefail (not -e), so a failed un-piped aws s3 cp was silently ignored — the task then ran with a missing input, "succeeded" with no output, and failed downstream with a confusing MissingFileException: Missing output file(s) *.html. Each input copy is now guarded with || { echo …; exit 1; } so a stage-in failure aborts loudly.

Tests

35 total, 0 failures. Updated the 3 #37 staging tests to the corrected expanding format; added a malformed-s3:/// repair test, a normalizeS3Uri unit test, and a fail-loud assertion.

Built + tested on JDK 17 / Nextflow 26.04.x.

The declared-input staging from #37/#38 emitted two broken commands so the
inputs were never actually copied (silently, since the script runs
`set -uo pipefail`, not `-e`):

  1. nf-amazon's S3 Path renders `toUri().toString()` with an empty authority
     (`s3:///bucket/key`, three slashes), so the bucket landed in the path and
     `aws s3 cp` parsed an empty bucket. normalizeS3Uri() now collapses the
     leading `s3:///` to `s3://`.
  2. The destination single-quoted the literal `${LOCAL_DIR}`, so the shell
     passed it to `aws` unexpanded — the file would have landed in a dir named
     `${LOCAL_DIR}`. `${LOCAL_DIR}/` is now kept outside the single quotes (only
     the stage name is quoted), matching how WORKDIR_S3/AWS_REGION are handled.

Also guards each input copy with `|| exit 1` so a failed stage-in fails loud
instead of letting the task run with a missing input and fail later with a
confusing MissingFileException.
@scttfrdmn
scttfrdmn merged commit 7505ef8 into main Jun 13, 2026
1 check passed
@scttfrdmn
scttfrdmn deleted the fix/41-s3-uri-and-localdir-expansion branch June 13, 2026 21:38
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.

buildInputStaging emits a malformed s3:/// URI and an unexpanded ${LOCAL_DIR} dest → declared inputs silently never copied

1 participant