fix(cli): fall back to BROWSERSTACK_BINARY_URL when update_cli fails (SDK-6948) - #224
Open
AakashHotchandani wants to merge 1 commit into
Open
AakashHotchandani wants to merge 1 commit into
AakashHotchandani wants to merge 1 commit into
Conversation
…(SDK-6948)
update_cli runs during bootstrap — before the binary spawns and before GRR
localizes hosts — so it always targets the prod api host. On an internal staging
run (BROWSERSTACK_STAGING_ENV) the staging creds are rejected there with 401,
leaving the CLI binary path empty and crashing the launcher with
spawn('') -> ERR_INVALID_ARG_VALUE ('file' cannot be empty).
Wrap the update_cli call: on failure, if BROWSERSTACK_BINARY_URL is set, download
the binary from that URL and use it; otherwise re-throw (behaviour unchanged when
the var is unset). Adds unit tests for both paths. v9 port of the v8 fix (PR #183),
validated end-to-end against devapplca (update_cli 401 -> fallback download from a
served zip -> binary spawned -> build-start reached).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited), Workspace UI (inherited) Review profile: ASSERTIVE Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
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
update_cliruns during bootstrap — before the CLI binary is spawned and before GRR localizes the API hosts — so it always targets productionapi.browserstack.com. On an internal staging run (BROWSERSTACK_STAGING_ENV) the staging credentials are rejected there (401).gotthrows,checkAndUpdateClipropagates,setupCliPathreturnsnull, and the launcher crashes:The binary is never downloaded (its URL comes from the
update_cliresponse, which never arrives), so nosdk-cli.logis produced.Fix
Wrap the
update_clicall in try/catch. On failure, ifBROWSERSTACK_BINARY_URLis set, download the binary from that URL and use it; otherwise re-throw (behaviour unchanged when the var is unset). This turnsBROWSERSTACK_BINARY_URLfrom a download-source override (only read after a successfulupdate_cli) into a real bootstrap fallback, so a worker can pull a binary from a URL even when the stagingapi-<env>/update_clitier is unreachable.Opt-in / zero default impact: with no
BROWSERSTACK_BINARY_URL, thecatchre-throws — identical to today. Same download + verification path (downloadLatestBinary). No auth bypass — the session's real calls (build-start, hub, testhub) still authenticate.Tests
cliUtils.test.tsfail onmainalready (pre-existingrequestToUpdateCLI/global.fetchdrift). Confirmed by running the suite onmainwith this change stashed (37 tests, same 3 fail) — not introduced here.Validation
Validated end-to-end on the v8 line (identical code path, PR #183): prod-mode run with
BROWSERSTACK_STAGING_ENV=devapplca+BROWSERSTACK_BINARY_URLpointing at a locally-served zip ->update_cli401 ->falling back to BROWSERSTACK_BINARY_URL-> binary downloaded (GET /binary.zip 200) -> spawned -> build-start reached. Thespawn('')crash is gone.Follow-up (separate): properly localize
update_cliviaBROWSERSTACK_STAGING_ENV(port of ruby-sdk SDK-6583) + bring up the stagingapi-<env>tier. This fallback is the production-safe bridge until then.🤖 Generated with Claude Code