Skip to content

fix(observability): read JSONWP session caps for platform and browser version [v10] - #409

Open
AakashHotchandani wants to merge 3 commits into
mainfrom
fix/jsonwp-session-caps-v10
Open

AakashHotchandani wants to merge 3 commits into
mainfrom
fix/jsonwp-session-caps-v10

Conversation

@AakashHotchandani

Copy link
Copy Markdown
Collaborator

What is this about?

Port of #377 (v9) and #374 (v8) to main (the v10 line). 10.0.0 / 10.0.1 were released without the fix.

For sessions that negotiate the JSONWP dialect, the test-run integrations carry no OS name and no browser version. Chrome 87 on Automate is one such case. TestHub then stores cbt_platform "Unknown," and cbt_browser "Chrome,Unknown", and TRA flags the build under metadata_issue_non_timeout.

Cause: a JSONWP session returns platform: 'WINDOWS' and version: '87.0.4280.66', with no platformName or browserVersion. Both integration builders read only the W3C keys:

  • InsightsHandler
  • TestReporter

The OS version can also be lost, because _userCaps may already hold the session caps without bstack:options.

Change (same as #377):

  • New util.ts helpers getSessionPlatformName and getSessionBrowserVersion fall back to platform and version when the W3C key is missing.
  • Both integration builders use them.
  • When the OS version can't be read from the user or session caps, it falls back to browser.requestedCapabilities.

The patch from #377 applied cleanly to insights-handler.ts, reporter.ts and util.ts on main. Only tests/util.test.ts needed a manual merge: both sides append new describe blocks at the end of the file, and both are kept.

Checks (local, Node 26; .nvmrc 22.23.4 also has zstd, Node 22.11 does not and fails to load undici):

  • npm run build passes (gRPC codegen, bundle, tsc -p tsconfig.prod.json).
  • eslint on the changed files: clean.
  • Full unit suite (npm test):
Test files Tests
main (91c0e3b) 8 failed, 50 passed 79 failed, 1442 passed (1521)
This branch 8 failed, 50 passed 78 failed, 1451 passed (1529)
  • The 8 new tests pass: 6 in util.test.ts (getSessionPlatformName / getSessionBrowserVersion), 2 in insights-handler.test.ts (JSONWP caps; requestedCapabilities OS-version fallback). With insights-handler.ts / reporter.ts reverted to main, both insights-handler cases fail (2 failed, 82 passed).
  • Every test that fails on this branch also fails on clean main (same names: service, util stopBuildUpstream / launchTestSession / uploadLogs / getAppA11yResults, funnelInstrumentation, crash-reporter, cliUtils, requestUtils, launcher). One launcher test failed only on the main run (flaky). The change adds no failures.

End-to-end evidence (from #377): Automate, Windows 11 + Chrome 87, before Unknown,Unknown / Chrome,Unknown (build 98brwkbu0rs0pwindxxvbkhykbsrak68r0jm3z6x), after Windows,11 / Chrome,87 (build oogqmhsirwvhyrwoyxomftjfstewwasrmn9ruhvs). In production, group 7416391 has 0 flagged builds on 8.56.2 (v8 fix).

Not verified:

  • No end-to-end run on a 10.x build.
  • Multiremote, Appium and Cucumber.

Related Jira task/s

Release (mandatory for every PR — required for the ready-for-review label)

Version bump: (required — tick exactly one)

  • minor (backwards-compatible feature)
  • patch (bug fix or other small change)

Release notes type: (optional)

  • New Feature
  • Bug Fix
  • Other Improvement

Release notes (customer-facing): (optional but encouraged)

  • Fixed the OS name and browser version showing as "Unknown" in Test Reporting & Analytics for sessions on older browsers such as Chrome 87.

Release notes (internal): (required — engineer-facing; what actually changed / why)

Checklist

  • Ready to review
  • Has it been tested locally?

PR Validations

Run Tests: Comment RUN_TESTS to trigger sanity tests.

🤖 Generated with Claude Code

… version [v10]

Port of #377 (v9) / #374 (v8) to main. Sessions that negotiate the JSONWP
dialect (e.g. Chrome 87 on Automate) return `platform`/`version` instead of
`platformName`/`browserVersion`, so TRA showed the OS and browser version as
"Unknown". getSessionPlatformName/getSessionBrowserVersion fall back to the
JSONWP keys, and platform_version falls back to the requested capabilities.

SDK-8256 (group 7416391)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 3, 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

  • Source mode: Auto (fallback from Default branch)
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML (base), Organization UI (inherited), Workspace UI (inherited); Enforced overrides: Organization
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: 603215d0-6a23-4d7e-aed9-db541e4b04d6

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@AakashHotchandani

Copy link
Copy Markdown
Collaborator Author

RUN_TESTS

@minionhelperappqa

Copy link
Copy Markdown

[SDK Wdio Test] TRA build state: failed | Stability 83% — verdict: failure. Passed: 48, Failed: 10, Aggregate: 58. TRA: https://observability.browserstack.com/builds/jprnedneen4aewxfvlpajtx6ez5k42w9gnfhyfir

@AakashHotchandani

Copy link
Copy Markdown
Collaborator Author

✅ Good to go — no blocking findings; 2 💡 suggestions below.

File Status Reason
.changeset/jsonwp-session-caps-v10.md 💡 Suggestion Duplicate of the bot-generated pr-409.md — delete this one (S1)
.changeset/pr-409.md ✅ All Clear Auto-generated by changeset-from-pr.yml — keep
packages/browserstack-service/src/insights-handler.ts ✅ All Clear Judged (two passes), no blocking finding
packages/browserstack-service/src/reporter.ts 💡 Suggestion Correct; new block has no test coverage (S2)
packages/browserstack-service/src/util.ts ✅ All Clear Judged, no blocking finding
packages/browserstack-service/tests/insights-handler.test.ts ✅ All Clear Judged (two passes), no blocking finding
packages/browserstack-service/tests/util.test.ts ✅ All Clear Judged, no blocking finding

💡 Suggestions (non-blocking)

S1 — Duplicate changeset. .changeset/jsonwp-session-caps-v10.md and .changeset/pr-409.md are byte-identical (same blob 6bc2c212), so the CHANGELOG would get the same bullet twice. pr-409.md was generated by github-actions[bot] via changeset-from-pr.yml from the PR's Release section (head commit b8d8460), and the workflow re-creates it on every push — so delete the hand-written jsonwp-session-caps-v10.md, not pr-409.md. (Same cleanup as 4e43ad0.)

S2 — reporter.ts path untested. The new JSONWP fallback in reporter.ts sits under /* istanbul ignore next */ and has no test; only the InsightsHandler path is covered. A small test with a JSONWP-shaped session (platform/version, no platformName/browserVersion) would lock it in.

Verified

  • platformName || platform / browserVersion || version still prefer W3C keys → W3C and Appium sessions unchanged; an empty W3C value now falls back to the legacy key (fine). browserName unchanged.
  • getPlatformVersion(undefined, requestedCapabilities) returns early when both are empty; bstack:options.osVersion resolves for standard caps. Multiremote / alwaysMatch-shaped caps still yield undefined — no regression, just not covered by this fix.
  • Tests: insights-handler.test 84/84 pass; reverting insights-handler.ts to main makes both new tests fail (they exercise the fix). util.test: all 6 new getSession* tests pass; the 15 other failures are identical on main (pre-existing, unrelated).

Change map (generated deterministically from the diff)

graph LR
  subgraph nwdio_service["wdio-service"]
    npackages_browserstack_service_src_reporter_ts["reporter.ts<br/>~19 lines"]
    npackages_browserstack_service_src_util_ts["util.ts<br/>~19 lines"]
    npackages_browserstack_service_tests_util_test_ts["util.test.ts<br/>~19 lines"]
    npackages_browserstack_service_src_insights_handler_ts["⚠ insights-handler.ts<br/>~14 lines"]
    npackages_browserstack_service_tests_insights_handler_test_ts["⚠ insights-handler.test.ts<br/>~14 lines"]
    n_changeset_jsonwp_session_caps_v10_md["jsonwp-session-caps-v10.md<br/>~5 lines"]
    n_changeset_pr_409_md["pr-409.md<br/>~5 lines"]
  end
Loading

↻ This verdict comment is the review anchor — it's updated in place on each run (the gate posts its status separately).

— SDK PR Review Agent

pr-409.md is auto-generated from the PR template by changeset-from-pr.yml
and is byte-identical; keeping both would duplicate the CHANGELOG entry.

Co-Authored-By: Claude Opus 5.5 <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.

1 participant