fix(bootstrap): don't die under pipefail when /etc/bux/env lacks a key#269
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
agent/bootstrap.shruns underset -euo pipefailand parses single keys out of/etc/bux/envwith: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,
grepexits 1,pipefailpropagates that through the command substitution, andset -ekills 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.shseeds/etc/bux/envwith onlyBROWSER_USE_API_KEY, soBUX_CP_CODEX_URLis always missing and every fresh AMI bake / cloud-repobux-boxbuild ofmainfails 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 devin the cloud repo on a fresh laptop).The same pattern is baked into the generated
/usr/local/bin/bu-cp-tokenhelper, which would exit 1 at runtime instead of printing empty whenBUX_BOX_TOKENis absent.Fix
Append
|| trueto both grep pipelines so a missing key yields the empty string the surrounding code already expects.Verification
Ran the bake path (
install.shthen thisbootstrap.shwith the systemctl shim,BROWSER_USE_API_KEY=build-placeholder) in an ubuntu:24.04 container:bootstrap: done, exit 0, withbootstrap: BUX_CP_CODEX_URL not set; skipping free-tier Codex provideron stderr as intended;bu-cp-tokenprints empty, exit 0Note for cloud-repo users: after this merges,
task bux:build:no-cacheis needed once to bust the stale clone layer.Summary by cubic
Stop bootstrap from exiting under
pipefailwhen/etc/bux/envlacks optional keys. This restores fresh AMI bakes andbux-boxbuilds by treating missing values as empty and skipping optional setup (ENG-4785).Bug Fixes
|| truetogreppipelines forBUX_CP_CODEX_URLandBUX_BOX_TOKENso missing keys yield empty strings.agent/bootstrap.shnow reaches the "not set; skipping..." path;bu-cp-tokenprints empty and exits 0.Migration
task bux:build:no-cacheonce in the cloud repo to clear cached layers.Written for commit 0256122. Summary will update on new commits.