Skip to content

Merge fix/SDK-4748-build-identifier-precedence - #251

Merged
Dalwin-Barnard merged 5 commits into
sdk_v9_pre_prodfrom
fix/SDK-4748-build-identifier-precedence
Sep 29, 2026
Merged

Dalwin-Barnard merged 5 commits into
sdk_v9_pre_prodfrom
fix/SDK-4748-build-identifier-precedence

Conversation

@bsautomation

Copy link
Copy Markdown
Contributor

Merge into sdk_v9_pre_prod :by automationbs

shivamku-BS and others added 5 commits September 27, 2026 14:45
…ifier

_handleBuildIdentifier deleted the buildIdentifier whenever
BROWSERSTACK_BUILD_NAME was exported, even though a buildName was present
in the capabilities and the identifier had been configured explicitly.
The clause was ported from the yml-driven SDKs, where it exists only to
suppress the *default* '#${BUILD_NUMBER}' identifier. This service has no
default identifier and never reads BROWSERSTACK_BUILD_NAME as a buildName
source, so the clause could only ever discard user intent.

Three changes, all aligning this service with the SDK-wide precedence
contract (CLI args > env vars > config file > script):

  - Skip the identifier only when there is no buildName at all.
  - Resolve BROWSERSTACK_BUILD_IDENTIFIER, then BROWSERSTACK_BUILD_RUN_IDENTIFIER,
    ahead of the service options / capabilities value. Neither env var was
    read before; they appeared only in telemetry payloads.
  - Sweep any remaining ${ENV_VAR} placeholder against process.env after the
    ${DATE_TIME} / ${BUILD_NUMBER} substitutions, leaving unset variables literal.

Mirrors browserstack-node-agent computeBuildIdentifier(),
browserstack-python-sdk ENV_CAPS_TO_CONFIG['buildIdentifier'] and
browserstack-csharp-sdk GetBuildIdentifier().

The unit test named "should delete buildIdentifier if BROWSERSTACK_BUILD_NAME
is defined as env var" asserted the broken behaviour by name only - its caps
carried no buildName, so it passed on the !this._buildName branch regardless.
It is replaced by a non-degenerate pair: one keeping the identifier when a
buildName is present, one still deleting it when it is absent.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…d tokens

Critical: the !buildName branch stripped buildIdentifier from capabilities but
left this._buildIdentifier set. launchTestSession reads that field for the
build-start payload's build_identifier, so an env-sourced value was reported to
O11y while never being applied to any capability. Pre-existing as a shape, but
the new env tier makes it reachable with zero user configuration, since CI
commonly injects BROWSERSTACK_BUILD_RUN_IDENTIFIER globally. Both the field and
browserStackConfig.buildIdentifier are now cleared alongside the caps update.

Warning: the generic ${ENV_VAR} sweep reprocessed ${BUILD_NUMBER}. When neither
getCiInfo() nor _getLocalBuildNumber() could resolve it the token was left
literal by design, and the sweep then substituted a raw process.env.BUILD_NUMBER
- without the 'CI ' prefix every other path applies. getCiInfo() recognises a
fixed vendor list that excludes GitHub Actions, and TeamCity exports a bare
BUILD_NUMBER, so this was reachable in practice. DATE_TIME and BUILD_NUMBER are
now excluded from the sweep.

Suggestion: `?? match` guarded only nullish, so an exported-but-empty variable
blanked that part of the identifier - contradicting the adjacent comment and
inconsistent with the tier-1 check, which treats whitespace-only as absent.
Empty and whitespace-only values now leave the literal placeholder.

Tests: the "buildName absent" case asserted only the caps side-effect, which the
pre-PR code would also have satisfied; it now asserts _buildIdentifier too. Added
regression tests for the reserved-token and empty-env cases. afterEach now clears
BUILD_NUMBER, so the pre-existing "stays literal" assertions no longer depend on
the ambient environment.

_handleBuildIdentifier block 17 -> 19 tests. Full suite 1347 passed (3 errors
pre-existing in uploadLogsArchive.test.ts, unchanged on a clean tree).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@bsautomation
bsautomation requested a review from a team as a code owner September 29, 2026 13:46
@bsautomation
bsautomation requested review from kamal-kaur04 and pranay-v29 and removed request for a team September 29, 2026 13:46
@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited), Workspace UI (inherited)

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 03a5f0b2-fbce-4abc-be6a-f96c7a40c0d3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@Dalwin-Barnard
Dalwin-Barnard merged commit d82f9e3 into sdk_v9_pre_prod Sep 29, 2026
18 of 20 checks passed
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.

4 participants