Skip to content

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

Closed

Description

@scttfrdmn

Follow-up to #37/#38/#39, on nf-spawn 0.2.10. #39's permission fix works (no more "Permission denied"; versions.yml writes). But the declared-input staging from #38 still doesn't land the file — and reading the actual generated staging script off the head node shows two concrete bugs in buildInputStaging's emitted commands.

Here are the verbatim stage-in lines nf-spawn 0.2.10 generated for a FASTQC task (task.getInputFilesMap() had the two read files):

# Localize declared inputs by source URI (#37 — they live outside this work dir).
aws s3 cp 's3:///scttfrdmn-microbiome-demo/work/microbiome-demo/fetch/21/e736.../SRR059375_stool_1.fastq.gz' '${LOCAL_DIR}/SRR059375_stool_1.fastq.gz' --region "${AWS_REGION}" --quiet
aws s3 cp 's3:///scttfrdmn-microbiome-demo/work/microbiome-demo/fetch/21/e736.../SRR059375_stool_2.fastq.gz' '${LOCAL_DIR}/SRR059375_stool_2.fastq.gz' --region "${AWS_REGION}" --quiet

Bug 1 — malformed s3:/// (three slashes, empty bucket/authority)

The source is s3:///scttfrdmn-microbiome-demo/work/... — three slashes. The bucket has landed in the path instead of the authority, so aws s3 cp parses an empty bucket and the copy fails. buildInputStaging uses source.toUri().toString(); for the S3 Path (nf-amazon) toUri() is rendering with an empty authority. Need to reconstruct the URI as s3://<bucket>/<key> — e.g. pull bucket from the path's first segment, or build from the filesystem's authority rather than toUri().toString() directly.

Bug 2 — ${LOCAL_DIR} is single-quoted in the destination, so it never expands

The dest is '${LOCAL_DIR}/SRR059375_stool_1.fastq.gz' — single-quoted. shellQuote() wraps the dest in single quotes, but the value still contains a literal shell variable ${LOCAL_DIR}, so the shell passes ${LOCAL_DIR}/... verbatim to aws s3 cp instead of /var/lib/nf-work/.... Even with bug 1 fixed, the file would land in a directory literally named ${LOCAL_DIR}. The ${LOCAL_DIR} prefix needs to be outside the single-quoted span (or the dest assembled so the var expands), the way WORKDIR_S3/AWS_REGION are handled elsewhere.

Why it's silent

The staging script is set -uo pipefail (not set -e), so a failed aws s3 cp (not part of a pipe) doesn't abort. The script continues, .command.sh runs, FASTQC finds no input → "Skipping '…raw_1.gz' which didn't exist", exits 0, produces no *.html, and Nextflow then fails the task with MissingFileException: Missing output file(s) *.html. So the trace shows FAILED but the real cause is upstream of the tool. Consider set -e (or an explicit check) around the stage-in copies so a failed input copy fails loud.

Good news in the same run

Env

nf-spawn 0.2.10, Nextflow 26.04.x, AL2023 arm64, workDir = s3://…, nf-amazon 2.8.0, inputs are s3:// paths from a samplesheet (taxprofiler). Observed 2026-06-13 by reading /tmp/nf-spawn-<inst>-*.sh on the head node.

Activity

  1. added
    bug
    on Jun 13, 2026
  2. scttfrdmn commented on Jun 13, 2026

    @scttfrdmn
    CollaboratorAuthor

    Fixed and released in v0.2.11 (#42) — ZIP is live: https://github.com/spore-host/nf-spawn/releases/tag/v0.2.11

    Thanks for reading the generated script off the head node — that pinned both bugs exactly.

    • Bug 1 (s3:///). New normalizeS3Uri() collapses the empty-authority s3:///bucket/key that nf-amazon's Path.toUri().toString() renders down to s3://bucket/key, so aws s3 cp parses a real bucket.
    • Bug 2 (${LOCAL_DIR} unexpanded). The dest now keeps ${LOCAL_DIR}/ outside the single quotes (only the stage name is quoted), so the shell expands it to /var/lib/nf-work/… — same treatment as WORKDIR_S3/AWS_REGION. Fixed for both the mkdir -p and the aws s3 cp.
    • Silent failure. Each input copy is now guarded with || { echo …; exit 1; }, so a failed stage-in aborts the script loudly instead of letting the task run input-less and surface later as a confusing MissingFileException.

    35 tests, 0 failures (updated the #37 staging tests to the corrected format + added repair/fail-loud cases).

    Bump your TARGET_NF_SPAWN_VERSION to 0.2.11. With #39 (perms) + #41 (the actual copy) both in, the FASTQC inputs should now land and the task should produce its *.html. If it does, that closes the loop on #37 staging end-to-end — the only thing I'd still expect to watch for is the .gz rename caveat from #37 if a stage name differs from the source basename.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions