Skip to content

compose_file_args()'s fatal exit 1 is silently neutered by mapfile < <(...) at all 4 call sites #7765

Description

@JSONbored

Context

compose_file_args() in scripts/lib/selfhost-deploy-common.sh:103-121 calls exit 1 (line 118) on a missing compose file, but every caller invokes it through a process substitution feeding mapfile:

mapfile -t compose_args < <(compose_file_args)

compose_file_args therefore always runs in a subshell; its exit 1 only kills that subshell. mapfile itself still returns 0 (an empty/partial read), so set -e never fires. Verified concretely: bash -c 'set -e; mapfile -t arr < <(false); echo "reached, len=${#arr[@]}"' prints reached, len=0 and exits 0.

Failure scenario: an operator with a stale/mistyped docker-compose.override.yml reference, or SELFHOST_COMPOSE_FILES pointing at a nonexistent file, gets the intended error: compose file not found: X printed to stderr, but the calling script (deploy-selfhost-image.sh:111, deploy-selfhost-prebuilt.sh:107, selfhost-post-update-check.sh:25, selfhost-post-update-regression-gate.sh:44) keeps running with an empty/truncated compose_args, invoking docker compose ... pull/up/ps with the wrong -f set instead of aborting cleanly.

Requirements

Replace the mapfile -t compose_args < <(compose_file_args) idiom at all 4 call sites with one that actually propagates compose_file_args's exit code under set -e — e.g. a checked plain command-substitution assignment (x=$(compose_file_args) does propagate failure; verified via bash -c 'set -e; foo(){ exit 3; }; x=$(foo); echo after' exiting 3, never reaching echo), or an explicit non-empty check on compose_args immediately after the mapfile call. Do not change compose_file_args's own logic — only how its callers consume its exit status.

Deliverables

  • All 4 callers (deploy-selfhost-image.sh, deploy-selfhost-prebuilt.sh, selfhost-post-update-check.sh, selfhost-post-update-regression-gate.sh) actually abort when compose_file_args fails.
  • A regression test (see the companion test-coverage issue for selfhost-deploy-common.sh if filed) or an inline test proving a missing compose file now aborts the calling script instead of continuing with empty/truncated args.

Test Coverage Requirements

test/unit/selfhost-deploy-common.test.ts exists but does not cover compose_file_args today. Add a test asserting the exit-propagation fix.

Expected Outcome

A missing/mistyped compose file reference during a self-host deploy aborts the deploy script immediately with the intended error, instead of silently continuing with an empty or truncated compose-file argument list.

Links & Resources

scripts/lib/selfhost-deploy-common.sh:103-121 (the function), lines 111/107/25/44 in the 4 caller scripts named above

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions