[SDK-7461] fix(setup-env): deliver BUILD_RUN_IDENTIFIER, ask the API when the triggering actor is unknown, stop failing re-run delivery silently - #88
Open
anish353 wants to merge 1 commit into
Conversation
…when the actor is unknown, stop failing silently Three changes to the BrowserStack re-run delivery path. 1. BROWSERSTACK_BUILD_RUN_IDENTIFIER has been dropped since 2026-05-07. The rebuild/details response carries three variables; the APS-19076 allowlist (8ade0a3) listed only two plus BUILD_NAME, so the identifier is filtered out and only a core.warning marks it. Verified against the live API. The SDKs send it as build_run_identifier in the build-start payload, which files a re-run as an attempt of its parent build rather than an unrelated build. PR #85's own body predicted this: "If the rerun API legitimately sets additional names in production, the list will need to grow." 2. An unreported GITHUB_TRIGGERING_ACTOR no longer aborts delivery. That variable comes from the runner binary, so a self-hosted runner can simply not set it. The actor check is only a cheap pre-filter — rebuild/details is the authority and returns no variables when BrowserStack did not trigger the re-run. Bailing on an absent actor turned a working re-run into a full-suite run on an otherwise correctly configured workflow. We now warn and ask the API instead. 3. Every remaining delivery failure names itself. With github-token at its 'none' default the job log was byte-identical to a healthy run, and the CLI then runs the full spec set because BROWSERSTACK_RERUN_TESTS is absent — so "all my tests ran again" was undiagnosable. checkIfBStackReRun now names the missing input, a human-triggered re-run says so, and an API failure is a warning rather than info. Attempt 1 stays silent: an ordinary run is not a degraded re-run. Verified end-to-end through the built dist into the real CLI across all eight delivery states, and reproduced against a real reported failure: the build ran 11 sessions, the targeted spec folder holds 11 specs, and the real CLI dispatches 11 with the list absent and 3 with it present. 47 tests passing (4 new), eslint clean, dist rebuilt with ncc (reproducible). Co-Authored-By: Claude Opus 5 <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.
Summary
Three defects in
setup-env's BrowserStack re-run delivery path, surfaced by a Cypress + GitHub Actions re-run investigation (SDK-7461).1.
BROWSERSTACK_BUILD_RUN_IDENTIFIERhas been silently dropped since 2026-05-07.The
rebuild/detailsresponse carries three variables. Verified against the live API (runId29728341550, HTTP 200):{"data":{"variables":{ "BROWSERSTACK_RERUN": "true", "BROWSERSTACK_RERUN_TESTS": "cypress/tests/FlightOffer/FO-E2E-05.ts,...", "BROWSERSTACK_BUILD_RUN_IDENTIFIER": "1784546348645-29728341550" }}}ALLOWED_RERUN_ENV_VARS(added in8ade0a3, APS-19076) lists only the first two plusBUILD_NAME, so the third is filtered out — the action logsIgnoring non-allowlisted env var from BrowserStack rerun API: BROWSERSTACK_BUILD_RUN_IDENTIFIERand moves on. Before8ade0a3the export loop was unfiltered, so this variable did reach the runner.The SDKs read it as
build_run_identifierin the build-start payload (browserstack-cypress-clibin/testObservability/helper/helper.js:412,bin/testhub/testhubHandler.js:65) — it is what files a re-run as an attempt of its parent build run rather than as an unrelated build.2. Every way re-run delivery can fail was silent.
With
github-tokenleft at itsaction.ymldefault of'none', the job log on a re-run is byte-identical to an ordinary run —checkIfBStackReRun()returnsfalsefrom two branches that log nothing. The CLI then runs the full spec set, because its only re-run switch is the presence ofBROWSERSTACK_RERUN_TESTS. So "all my tests ran again instead of just the failed ones" was undiagnosable from the log, which is how SDK-7124 and SDK-7461 both stalled.checkIfBStackReRun()now names the missing input, explains a human-triggered re-run, and an API failure is acore.warningrather thancore.info. An absentGITHUB_TRIGGERING_ACTORgets its own message rather than the App-not-installed one — that variable comes from the runner binary, so on a self-hosted runner it can simply be missing, and blaming the GitHub App there sends the reader after an install that is fine. Attempt 1 stays silent — an ordinary run is not a degraded re-run.PR #85 predicted this. The allowlist's own PR body carries the caveat verbatim:
BROWSERSTACK_BUILD_RUN_IDENTIFIERis exactly such a name. The warning has been emitted on every BrowserStack-triggered re-run since 2026-05-07; nobody was watching for it. This PR is that predicted growth.3. An unreported
GITHUB_TRIGGERING_ACTORaborted delivery on an otherwise correct setup.checkIfBStackReRun()bailed when that variable was absent. But it comes from the runner binary, so a self-hosted runner can simply not set it — and the actor check is only a cheap pre-filter:rebuild/detailsis the authority and returns no variables when BrowserStack did not trigger the re-run. So the bail converted a working re-run into a full-suite run. It now warns and asks the API instead. This surfaced on a self-hosted Windows runner fleet, where the variable was not being set.Security note (APS-19076 preserved)
The allowlist still blocks arbitrary names; only one BrowserStack-owned, BrowserStack-consumed name is added. The existing negative test asserting
NODE_OPTIONS/PATH/GITHUB_TOKENare rejected is unchanged and passing.Testing
distrebuilt with ncc, reproducible (a secondnpm run buildgives no further diff).dist/index.js, run exactly as a GitHub runner does (INPUT_*env, output read from$GITHUB_ENV), against the real details API:BUILD_RUN_IDENTIFIERunset +::warning::Ignoring non-allowlisted…BUILD_RUN_IDENTIFIER=1784546348645-29728341550, no warninggithub-token=noneon a re-run::warning::…the 'github-token' input is not set. Every test will run again…Triggering actor is - <x>onlyGITHUB_TRIGGERING_ACTORcore.info, easily missed::warning::naming the failure and its consequenceReproduced against a real reported failure
The reported build ran 11 sessions; the spec folder its workflow targets via
--specholds exactly 11 specs. Driving the real published CLI over that project with the same arguments:BROWSERSTACK_RERUN_TESTSThat workflow is correctly configured (step present with
github-token, same job, beforeRun Tests, no env shadowing, CLI unpinned → 1.36.19), which is what pointed at change 3.Blast radius
Small, but not zero. Change 3 means workflows whose runner does not report a triggering actor will now make one extra authenticated GET on re-run attempts (>1) and, when BrowserStack did trigger the re-run, will start receiving the failed-test list they should always have had. Workflows on a BrowserStack-triggered re-run will now additionally receive
BROWSERSTACK_BUILD_RUN_IDENTIFIER— the SDKs already read it and it was present before APS-19076, so this restores prior behaviour rather than introducing new behaviour. The rest is log-only. All eight delivery states were exercised end-to-end through the built action into the real CLI; seven of eight produce a full-suite re-run, and post-fix each carries a distinct signature. Docs recommend pinning@master, so this reaches everysetup-envuser on merge.Ref: SDK-7461, SDK-7124.
🤖 Generated with Claude Code