Skip to content

Fix the silent exit right after 'key accepted' - #4

Merged
BeLazy167 merged 2 commits into
mainfrom
fix/pipefail-silent-exit
Aug 20, 2026
Merged

Fix the silent exit right after 'key accepted'#4
BeLazy167 merged 2 commits into
mainfrom
fix/pipefail-silent-exit

Conversation

@BeLazy167

Copy link
Copy Markdown
Member

The first real install (thanks for being the guinea pig) died with no output at
all immediately after + key accepted (from pasted).

Two causes, reproduced then fixed

1. set -e + pipefail + a grep that matches nothing. The JSON extractors
are grep | head | sed pipelines. When the field is absent — a normal outcome,
not an error — grep exits 1, pipefail makes the pipeline non-zero, and set -e
kills the installer mid-assignment with no message. The extractors now disable
pipefail inside their own subshell and return empty.

2. The org-name lookup lost its X-Organization-Id header in an earlier
refactor, so /organizations/current returned an error body — which has no
name, handing cause 1 exactly the absent field that detonated it.

Regression test

tests/extractors.sh extracts the real json_str/json_num definitions out
of install.sh (not a copy that can drift) and calls them on bodies missing the
field, under set -euo pipefail. A reintroduction fails CI on both platforms.

Also swept the rest: the only other unguarded grep-in-substitution is in
statusline.sh, which has no set -e and already tolerates the failure.

Verified

  • The exact reproduction script now survives on bash 5 and macOS bash 3.2.
  • shellcheck -S warning clean; tests/statusline.sh 12/12; tests/extractors.sh 5/5.

The first real install died with no message the moment the key was accepted.
Two causes, found by reproducing it:

- install.sh runs under `set -euo pipefail`, and the JSON extractors are grep
  pipelines. A grep that matches nothing makes the pipeline non-zero, so an
  absent field — a normal outcome, e.g. an error body with no `name` — killed
  the whole script via set -e, silently. The extractors now disable pipefail
  in their own subshell and return empty instead.
- The /organizations/current lookup lost its X-Organization-Id header in an
  earlier refactor, so it returned an error body and handed the extractor
  exactly that absent field.

tests/extractors.sh pins the fix by pulling the real function definitions out
of install.sh (not a copy that can drift) and calling them on bodies missing
the field, under the same shell options. Wired into CI on both platforms.
@BeLazy167
BeLazy167 merged commit 559fbd7 into main Aug 20, 2026
6 checks passed
@BeLazy167
BeLazy167 deleted the fix/pipefail-silent-exit branch August 20, 2026 21:17
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