Skip to content

fix(bootstrap): don't die under pipefail when /etc/bux/env lacks a key#269

Merged
Alezander9 merged 1 commit into
mainfrom
fix/bootstrap-env-grep-pipefail
Jul 2, 2026
Merged

fix(bootstrap): don't die under pipefail when /etc/bux/env lacks a key#269
Alezander9 merged 1 commit into
mainfrom
fix/bootstrap-env-grep-pipefail

Conversation

@Alezander9

@Alezander9 Alezander9 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Problem

agent/bootstrap.sh runs under set -euo pipefail and parses single keys out of /etc/bux/env with:

BUX_CP_CODEX_URL="$(grep -E '^BUX_CP_CODEX_URL=' /etc/bux/env | tail -n1 | cut -d= -f2- | tr -d '"'\''')"

When the key is absent, grep exits 1, pipefail propagates that through the command substitution, and set -e kills the script — silently, since a no-match grep prints nothing. Both call sites already handle the empty-string result explicitly ("not set; skipping..."); execution just never reaches them.

At bake time install.sh seeds /etc/bux/env with only BROWSER_USE_API_KEY, so BUX_CP_CODEX_URL is always missing and every fresh AMI bake / cloud-repo bux-box build of main fails since #264/#267 (ENG-4785). Existing machines were shielded by cached docker layers holding a pre-ENG-4785 clone; new machines hit it immediately (this is how it was found — task dev in the cloud repo on a fresh laptop).

The same pattern is baked into the generated /usr/local/bin/bu-cp-token helper, which would exit 1 at runtime instead of printing empty when BUX_BOX_TOKEN is absent.

Fix

Append || true to both grep pipelines so a missing key yields the empty string the surrounding code already expects.

Verification

Ran the bake path (install.sh then this bootstrap.sh with the systemctl shim, BROWSER_USE_API_KEY=build-placeholder) in an ubuntu:24.04 container:

  • before: silent exit 1 right after "pip installing"
  • after: bootstrap: done, exit 0, with bootstrap: BUX_CP_CODEX_URL not set; skipping free-tier Codex provider on stderr as intended; bu-cp-token prints empty, exit 0

Note for cloud-repo users: after this merges, task bux:build:no-cache is needed once to bust the stale clone layer.


Summary by cubic

Stop bootstrap from exiting under pipefail when /etc/bux/env lacks optional keys. This restores fresh AMI bakes and bux-box builds by treating missing values as empty and skipping optional setup (ENG-4785).

  • Bug Fixes

    • Added || true to grep pipelines for BUX_CP_CODEX_URL and BUX_BOX_TOKEN so missing keys yield empty strings.
    • agent/bootstrap.sh now reaches the "not set; skipping..." path; bu-cp-token prints empty and exits 0.
  • Migration

    • Run task bux:build:no-cache once in the cloud repo to clear cached layers.

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

Review in cubic

grep exits 1 on no match, which pipefail propagates through the
command substitution and set -e turns into a silent script death.
Both call sites already handle the empty-string case explicitly;
they just never got there. This broke every fresh AMI bake /
bux-box build since the env file only seeds BROWSER_USE_API_KEY
at bake time (cached docker layers hid it from existing machines).

Same fix for the generated bu-cp-token helper, which would exit 1
at runtime instead of printing empty when the token key is absent.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

@Alezander9 Alezander9 merged commit 345ecbd into main Jul 2, 2026
7 checks passed
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