Skip to content

Merge fix/SDK-4177-cli-flow-screenshot-log - #208

Merged
rahulpsq merged 8 commits into
sdk_v9_pre_prodfrom
fix/SDK-4177-cli-flow-screenshot-log
Sep 18, 2026
Merged

rahulpsq merged 8 commits into
sdk_v9_pre_prodfrom
fix/SDK-4177-cli-flow-screenshot-log

Conversation

@bsautomation

Copy link
Copy Markdown

Merge into sdk_v9_pre_prod :by automationbs

anish353 and others added 8 commits September 9, 2026 21:22
`InsightsHandler.browserCommand` is the only producer of TEST_SCREENSHOT
logs, and its two call sites both sat behind `!BrowserstackCLI.isRunning()`.
Since `CLISupportedFrameworks = ['mocha']`, every Mocha run took the binary
flow and lost screenshots entirely — Observability received a test run with
no TEST_LOG artifact, so no screenshots manifest. Jasmine and Cucumber, which
stay on the Direct flow, were unaffected.

Subscribe to the result event on the binary path as well. `command`
(beforeCommand) is deliberately left unsubscribed: it only fills the map the
HTTP-log half of `browserCommand` reads, and that half emits on the JS
listener pipeline the binary owns here — so the screenshot upload, which
rides its own JWT-authenticated endpoint, stays the single effect.

Also honour an explicit denial: `allow_screenshots` is an optional *string*
on the wire, so a denial arrives as `'false'`, which `Boolean()` read as
permission granted. Same defect class `shouldProcessEventForTesthub` already
guards against with `isTrue`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`.github/PULL_REQUEST_TEMPLATE.md` states the changeset is generated from the
PR's Release section as `.changeset/pr-<number>.md`, so a hand-written one is
redundant here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Follow-up to the previous commit, which subscribed the result event on the
binary path but stopped one step short — verified end to end and the
screenshot still never reached Observability. Two further links were broken:

1. `browserCommand` uploaded via `listener.onScreenshot`, whose endpoint
   answers 401 to the binary's JWT (`[screenshot_upload] Failed ... status:
   401`). On this path the binary owns reporting, so the entry now rides the
   same LOG rail `appendTestItemLog` uses: the CLI stamps the test uuid and
   forwards it over gRPC.

2. `loadLogEntries` hardcoded `logRecord.kind = KIND_LOG`, destructuring only
   `{level, message, timestamp}` and discarding the producer's kind — so the
   screenshot arrived labelled as a console log and no screenshots manifest
   was built. It now keeps an explicit kind and falls back to KIND_LOG, which
   is what the previously-unreferenced KIND_SCREENSHOT constant was for.
   Console logs are unchanged: `StdLog.kind` is already 'TEST_LOG'.

Verified on a real build: two `"kind":"TEST_SCREENSHOT"` entries on the gRPC
wire, `retries[].logs == ['TEST_LOG']` on both leaves, and BStackAutomation's
`validate_o11y_screenshot` returning True for both test ids (0/2 failures).

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

Review finding 1. `getTestFramework()` can be undefined while `isRunning()` is
true — the dev-env short-circuit returns true before `setupTestFramework()` has
run, and that only assigns for webdriverio-mocha — so the non-null assertion
could throw. `o11yClassErrorHandler` wraps every InsightsHandler method and
catches async rejections, so it could not break the customer's test, but the
screenshot was thrown away silently.

Resolve the framework and fall back to the direct upload when it is absent, so
an untracked framework still gets its one chance at reporting the screenshot.

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

coderabbitai Bot commented Sep 18, 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: 8f7cbd8b-3f13-4947-b7e6-b05242791242

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.

@rahulpsq
rahulpsq merged commit 12b27f6 into sdk_v9_pre_prod Sep 18, 2026
23 of 24 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.

3 participants