Skip to content

[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
browserstack:masterfrom
rounak610:fix/sdk-7461-do-not-override-unset-build-project-name
Open

[SDK-7461] fix(setup-env): do not export a build/project name the workflow never set#87
rounak610 wants to merge 2 commits into
browserstack:masterfrom
rounak610:fix/sdk-7461-do-not-override-unset-build-project-name

Conversation

@rounak610

@rounak610 rounak610 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

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-env and verified by executing the built action, not by reading source. The change is confined to setup-env.

Issue — env-injected defaults silently outrank browserstack.json (SDK-7461)

ActionInput.setEnvVariables() in setup-env/src/actionInput/index.js exported BROWSERSTACK_PROJECT_NAME and BROWSERSTACK_BUILD_NAME unconditionally, even when the workflow supplied neither project-name nor build-name:

core.exportVariable(ENV_VARS.BROWSERSTACK_PROJECT_NAME, this.projectName);
core.exportVariable(ENV_VARS.BROWSERSTACK_BUILD_NAME, this.buildName);

By this point _validateInput() has already replaced the two blank inputs with generated defaultsvalidateProjectName()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.yml and silently replaces it, with no way to opt out.

Customer impact. easyJet's browserstack.json declares E2E_Automation for both names. Their failing build instead showed:

project : core-automation-framework          (= their repo name)
build   : workflow_dispatch [Workflow: 7]     (= <event> [Workflow: <run#>])

Neither string exists anywhere in their repository. This was our own remedy in SDK-7124, which told them to add setup-env with only username, access-key and github-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-framework and workflow_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.info line and leave the variable unset so the user's own configuration wins.

  • Captured buildNameProvided / projectNameProvided in 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.
  • Guarded both core.exportVariable calls on those flags.
  • The generated values are not lost: InputValidator already understands the BUILD_INFO and REPO_NAME tokens (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.
  • Rebuilt setup-env/dist/index.js with ncc (the committed bundle is what the action runs). Verified reproducible: a fresh npm run build produces zero diff against the committed dist.

⚠️ Blast radius — please read before merging

This changes behaviour for every workflow that uses setup-env without build-name/project-name and 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:

with:
  build-name: BUILD_INFO
  project-name: REPO_NAME

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-env inputs / workflow master with this fix
no names, no --build-name SPLIT MATCH
no names, with --build-name SPLIT MATCH
explicit names, no --build-name MATCH MATCH
explicit names + differing --build-name SPLIT SPLIT¹

¹ The last row is a separate CLI name-precedence gap (browserstack-cypress-cli), tracked independently — not in scope for this setup-env change.

Testing

Suite master this branch
setup-env mocha 37 passing / 0 failing 43 passing / 0 failing
setup-env eslint clean clean
dist reproducibility npm run build → 0 diff

Node 20 (v20.11.1), npm test (lint + mocha). Six new test cases assert the guarded behaviour:

  • Records that build-name and project-name were supplied
  • Records that build-name and project-name were NOT supplied when absent
  • Treats a whitespace-only name input as not supplied
  • Does not export BROWSERSTACK_PROJECT_NAME when no project-name input was given
  • Does not export BROWSERSTACK_BUILD_NAME when no build-name input was given
  • Exports neither name when neither input was given, leaving the user config to win

Ticket: SDK-7461 · Predecessor context: SDK-7124

🤖 Generated with Claude Code

…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>
@rounak610
rounak610 requested a review from a team as a code owner September 4, 2026 06:18
Comment thread setup-env/dist/index.js Outdated
// 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

trim too many code comments

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in d2e8a43 — source comment reduced from 8 lines to 2 and dist rebuilt from it. 43 tests still passing, eslint clean.

Comment thread setup-env/dist/index.js
// 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());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trim it here as well

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Comment thread setup-env/src/actionInput/index.js Outdated
// 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trim comments

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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>
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.

3 participants