[SDK-7461] fix(setup-env): do not export a build/project name the workflow never set - #87
Open
rounak610 wants to merge 2 commits into
Conversation
…er set setEnvVariables() exported BROWSERSTACK_BUILD_NAME and BROWSERSTACK_PROJECT_NAME unconditionally. When the workflow supplied neither input, _validateInput() had already replaced them with generated defaults -- the repo name, and "<event> [Workflow: <n>]" -- so the action exported values the user never asked for. Every BrowserStack SDK resolves names as CLI args > env vars > config file. An exported default therefore does not fill a gap, it OUTRANKS whatever the user configured and silently replaces it. A customer following our own documented setup for re-run delivery saw their browserstack.json project_name/build_name of "E2E_Automation" replaced by "core-automation-framework" and "workflow_dispatch [Workflow: 7]". Export each variable only when its input was actually supplied. The generated values remain available through the BUILD_INFO and REPO_NAME tokens that InputValidator already understands -- which is what those tokens were for. When an input is omitted the action now logs that it left the variable unset, so the behaviour is visible in the workflow log. Ref: SDK-7461 (follow-on to SDK-7124) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
| // Every BrowserStack SDK resolves names as: CLI args > env vars > config file. | ||
| // Exporting a generated default here therefore does not "fill a gap" -- it | ||
| // OUTRANKS whatever the user configured in browserstack.json / browserstack.yml | ||
| // and silently replaces it. Users who want the generated values still get them |
Collaborator
Author
There was a problem hiding this comment.
Done in d2e8a43 — source comment reduced from 8 lines to 2 and dist rebuilt from it. 43 tests still passing, eslint clean.
| // Whether the workflow actually asked us for a name. _validateInput() replaces | ||
| // both fields with generated defaults when they are blank, so the only place | ||
| // this can be observed is here, before validation runs. | ||
| this.buildNameProvided = Boolean(this.buildName && this.buildName.trim()); |
Collaborator
Author
There was a problem hiding this comment.
Done in d2e8a43 — this is the bundled dist; regenerated with npm run build (ncc) after trimming the source comment, so it now carries the shortened version.
| // Every BrowserStack SDK resolves names as: CLI args > env vars > config file. | ||
| // Exporting a generated default here therefore does not "fill a gap" -- it | ||
| // OUTRANKS whatever the user configured in browserstack.json / browserstack.yml | ||
| // and silently replaces it. Users who want the generated values still get them |
Collaborator
Author
There was a problem hiding this comment.
Done — trimmed to a single line in d2e8a43, keeping just the non-obvious why (capture must happen before _validateInput() replaces blanks with generated defaults).
Address review feedback on PR browserstack#87 (shayan-bstack): reduce the two explanatory comment blocks to the essential rationale, matching the file's existing comment density. Rebuilt dist. No behaviour change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
shayan-bstack
approved these changes
Sep 7, 2026
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.
SDK-7461 fix(setup-env): do not export a build/project name the workflow never set
Fixes the customer-facing bug in SDK-7461 (easyJet). Root-caused to
setup-envand verified by executing the built action, not by reading source. The change is confined tosetup-env.Issue — env-injected defaults silently outrank
browserstack.json(SDK-7461)ActionInput.setEnvVariables()insetup-env/src/actionInput/index.jsexportedBROWSERSTACK_PROJECT_NAMEandBROWSERSTACK_BUILD_NAMEunconditionally, even when the workflow supplied neitherproject-namenorbuild-name:By this point
_validateInput()has already replaced the two blank inputs with generated defaults —validateProjectName()→github.context.repo.repo(the repo name),validateBuildName()→_getBuildInfo()→<event> [Workflow: <run number>].Every BrowserStack SDK resolves names as CLI args > env vars > config file. So exporting a generated default does not fill a gap — it outranks whatever the user configured in
browserstack.json/browserstack.ymland silently replaces it, with no way to opt out.Customer impact. easyJet's
browserstack.jsondeclaresE2E_Automationfor both names. Their failing build instead showed:Neither string exists anywhere in their repository. This was our own remedy in SDK-7124, which told them to add
setup-envwith onlyusername,access-keyandgithub-token— so the defaults fired and discarded their config. It also explains the reported "build missing from the old dashboard": TRA reads the env var, Automate reads the config, so the two dashboards filed the run under different names.Reproduced by execution. Running the built action as a runner does, with the exact SDK-7124 inputs, produced
core-automation-frameworkandworkflow_dispatch [Workflow: 7]byte-for-byte.Fix
Export each name variable only when its input was actually supplied; when it was left blank, log an explicit
core.infoline and leave the variable unset so the user's own configuration wins.buildNameProvided/projectNameProvidedin the constructor, before_validateInput()overwrites the blanks with generated defaults — that is the only point where "did the workflow ask for a name?" is still observable.core.exportVariablecalls on those flags.InputValidatoralready understands theBUILD_INFOandREPO_NAMEtokens (documented in the README). Those tokens are the intended, explicit opt-in — applying them implicitly is what made them redundant and what broke user config. README updated to document this.setup-env/dist/index.jswithncc(the committed bundle is what the action runs). Verified reproducible: a freshnpm run buildproduces zero diff against the committeddist.This changes behaviour for every workflow that uses
setup-envwithoutbuild-name/project-nameand relies on the generated names. Their builds now fall back to whatever the SDK/config resolves. Any such user restores the previous behaviour with one line:Our docs recommend pinning
@master, so this reaches every user the moment it merges — there is no gradual rollout. This warrants a maintainer call on timing and a release note. Flagging explicitly rather than assuming.Verified behaviour matrix
Does the TRA dashboard name agree with the Automate dashboard name?
setup-envinputs / workflow--build-name--build-name--build-name--build-name¹ The last row is a separate CLI name-precedence gap (
browserstack-cypress-cli), tracked independently — not in scope for thissetup-envchange.Testing
setup-envmochasetup-enveslintdistreproducibilitynpm run build→ 0 diffNode 20 (
v20.11.1),npm test(lint + mocha). Six new test cases assert the guarded behaviour:BROWSERSTACK_PROJECT_NAMEwhen no project-name input was givenBROWSERSTACK_BUILD_NAMEwhen no build-name input was givenTicket: SDK-7461 · Predecessor context: SDK-7124
🤖 Generated with Claude Code