Skip to content

fix(browserstack-service): omit unset accessibility config#15215

Merged
wswebcreation merged 1 commit into
webdriverio:mainfrom
kbrooks:fix-browserstack-accessibility-null-config
May 17, 2026
Merged

fix(browserstack-service): omit unset accessibility config#15215
wswebcreation merged 1 commit into
webdriverio:mainfrom
kbrooks:fix-browserstack-accessibility-null-config

Conversation

@kbrooks
Copy link
Copy Markdown
Contributor

@kbrooks kbrooks commented Apr 23, 2026

Summary

  • stop treating an unset BrowserStack accessibility option as a nullable value
  • avoid propagating accessibility: null through BrowserStack service config and product-map metadata
  • preserve explicit accessibility enablement when it is actually configured

Problem

In WDIO v9 BrowserStack service flows, sessions can fail before creation with an error like:

WebDriverError: The property "#/alwaysMatch/bstack:options/accessibility" of type NilClass did not match one or more of the following types: boolean, string

We traced this to wdio-browserstack-service carrying accessibility state as boolean | null and then serializing that unset state into BrowserStack CLI/session config as accessibility: null.

The failure was reproducible in BrowserStack-backed Selenium preprod runs even when the user config did not set any accessibility option.

Root cause

The regression appears to come from the v9 accessibility auto-enable path introduced in a0bc710 (Auto enable accessibility [v9]).

That change introduced nullable accessibility state and propagated it through:

  • BrowserStackConfig.accessibility
  • launcher _accessibilityAutomation
  • build start product-map/config generation

Using undefined for the unset case is safer here because it omits the field instead of sending null to BrowserStack.

Fix

  • make the stored accessibility config optional instead of boolean | null
  • remove the default accessibility: false option from DEFAULT_OPTIONS
  • avoid writing nullable accessibility state back into launcher/config state
  • keep product maps typed to allow undefined when accessibility is not configured

@kbrooks kbrooks requested a review from a team as a code owner April 23, 2026 20:11
@xxshubhamxx
Copy link
Copy Markdown
Contributor

@christian-bromann Could you review and merge this PR?

@wswebcreation wswebcreation added the PR: Polish 💅 PRs that contain improvements on existing features label May 17, 2026
@wswebcreation wswebcreation merged commit b4ba956 into webdriverio:main May 17, 2026
3 checks passed
@dprevost-LMI
Copy link
Copy Markdown
Contributor

dprevost-LMI commented May 23, 2026

Hey @kbrooks (and @wswebcreation), if I'm not mistaken, this PR is breaking npm run setup on main with the below.
I tested a reverted commit, and it seemed to work, but fixing the issue would be better. I did not take the time to understand the situation.

> @wdio/browser-runner@9.27.1 build:copy:js /Users/webdriverio/packages/wdio-browser-runner
> sed '$d' ./node_modules/mocha/mocha.js > ./build/third_party/mocha.js

[@wdio/browser-runner] ✅ Successfully ran build script for @wdio/browser-runner: "run-s build:*"
/Users/webdriverio/node_modules/.pnpm/esbuild@0.27.3/node_modules/esbuild/lib/main.js:1467
  let error = new Error(text);
              ^

Error: Build failed with 1 error:
error: [@wdio/browserstack-service] Failed to generate d.ts files: TypeScript compilation failed with code 2
src/instrumentation/funnelInstrumentation.ts(143,9): error TS2322: Type '{ [key: string]: boolean | undefined; }' is not assignable to type '{ [key: string]: boolean; }'.
  'string' index signatures are incompatible.
    Type 'boolean | undefined' is not assignable to type 'boolean'.
      Type 'undefined' is not assignable to type 'boolean'.
src/launcher.ts(975,66): error TS2322: Type '{ [key: string]: boolean | undefined; }' is not assignable to type '{ [key: string]: boolean; }'.
  'string' index signatures are incompatible.
    Type 'boolean | undefined' is not assignable to type 'boolean'.
      Type 'undefined' is not assignable to type 'boolean'.
src/launcher.ts(995,29): error TS2322: Type '{ [key: string]: boolean | undefined; }' is not assignable to type '{ [key: string]: boolean; }'.
  'string' index signatures are incompatible.
    Type 'boolean | undefined' is not assignable to type 'boolean'.
      Type 'undefined' is not assignable to type 'boolean'.
src/launcher.ts(1014,25): error TS2322: Type '{ [key: string]: boolean | undefined; }' is not assignable to type '{ [key: string]: boolean; }'.
  'string' index signatures are incompatible.
    Type 'boolean | undefined' is not assignable to type 'boolean'.
      Type 'undefined' is not assignable to type 'boolean'.
src/launcher.ts(1033,99): error TS2322: Type '{ [key: string]: boolean | undefined; }' is not assignable to type '{ [key: string]: boolean; }'.
  'string' index signatures are incompatible.
    Type 'boolean | undefined' is not assignable to type 'boolean'.
      Type 'undefined' is not assignable to type 'boolean'.
src/launcher.ts(1052,25): error TS2322: Type '{ [key: string]: boolean | undefined; }' is not assignable to type '{ [key: string]: boolean; }'.
  'string' index signatures are incompatible.
    Type 'boolean | undefined' is not assignable to type 'boolean'.
      Type 'undefined' is not assignable to type 'boolean'.
src/launcher.ts(1071,21): error TS2322: Type '{ [key: string]: boolean | undefined; }' is not assignable to type '{ [key: string]: boolean; }'.
  'string' index signatures are incompatible.
    Type 'boolean | undefined' is not assignable to type 'boolean'.
      Type 'undefined' is not assignable to type 'boolean'.
src/util.ts(403,67): error TS2345: Argument of type 'boolean | null' is not assignable to parameter of type 'boolean | undefined'.
  Type 'null' is not assignable to type 'boolean | undefined'.

    at failureErrorWithLog (/Users/webdriverio/node_modules/.pnpm/esbuild@0.27.3/node_modules/esbuild/lib/main.js:1467:15)
    at /Users/webdriverio/node_modules/.pnpm/esbuild@0.27.3/node_modules/esbuild/lib/main.js:926:25
    at /Users//webdriverio/node_modules/.pnpm/esbuild@0.27.3/node_modules/esbuild/lib/main.js:1345:9
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5) {
  errors: [Getter/Setter],
  warnings: [Getter/Setter]
}

Node.js v24.11.1

@kbrooks
Copy link
Copy Markdown
Contributor Author

kbrooks commented May 23, 2026

Yeah it got merged with a failing check somehow so it's probably broken

@kbrooks
Copy link
Copy Markdown
Contributor Author

kbrooks commented May 23, 2026

@dprevost-LMI I have a fix here #15262

dprevost-LMI pushed a commit that referenced this pull request May 24, 2026
* fix(browserstack-service): restore boolean product map types after #15215

PR #15215 loosened getProductMap's return to `{ [key: string]: boolean | undefined }`,
which broke the public `Capabilities.buildProductMap` and `EventProperties.productMap`
contracts (both `{ [key: string]: boolean }`). It also left launchTestSession
declaring `accessibilityAutomation: boolean | null` while the launcher now passes
`boolean | undefined`, producing 9 TS errors during `npm run setup`.

Coerce `config.accessibility` (`boolean | undefined`) to `boolean` via
`=== true` in getProductMap, and align launchTestSession's parameter to
`?: boolean`. Preserves the PR's "omit unset accessibility" intent for the
build-start payload without leaking `undefined`/`null` into typed boolean
capabilities.

* test(browserstack-service): cover getProductMap undefined-accessibility branch

* test(browserstack-service): cover getProductMap accessibility: true case

---------

Co-authored-by: Kyle Brooks <1072367+kbrooks@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Polish 💅 PRs that contain improvements on existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants