From 78860ab28bea42e2ad9b93ca81e36406df9f9df3 Mon Sep 17 00:00:00 2001 From: Anish Sinha Date: Fri, 24 Jul 2026 17:27:22 +0530 Subject: [PATCH 01/11] fix(cli): read apis from config.sessionData with flat fallback (SDK-6821 Phase 3) The binary is relocating internal fields off session.config into a namespaced sessionData bucket in the StartBinSession/ConnectBinSession echo. Prefer config.sessionData.apis at the single parse site (setConfig serves both RPC paths), falling back to the flat config.apis so the service works against both old and new binaries. Co-Authored-By: Claude Fable 5 --- packages/browserstack-service/src/cli/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/browserstack-service/src/cli/index.ts b/packages/browserstack-service/src/cli/index.ts index 618ca48..b1b3cc3 100644 --- a/packages/browserstack-service/src/cli/index.ts +++ b/packages/browserstack-service/src/cli/index.ts @@ -529,6 +529,9 @@ export class BrowserstackCLI { setConfig(response: StartBinSessionResponse) { try { this.config = JSON.parse(response.config) + // Binary now nests apis under config.sessionData; prefer it, fall back to the flat config.apis (SDK-6821 Phase 3) + const sessionData = this.config.sessionData as { apis?: unknown } | undefined + this.config.apis = sessionData?.apis ?? this.config.apis const redactedConfig = JSON.parse(response.config) CrashReporter.recursivelyRedactKeysFromObject(redactedConfig, ['user', 'username', 'key', 'accesskey', 'password']) this.logger.debug(`loadModules: config=${JSON.stringify(redactedConfig)}`) From c5373b43fa1789a812fa0f427e44b54c3e5b5426 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Jul 2026 11:57:56 +0000 Subject: [PATCH 02/11] chore(changeset): auto-generate from PR template (patch) --- .changeset/pr-89.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pr-89.md diff --git a/.changeset/pr-89.md b/.changeset/pr-89.md new file mode 100644 index 0000000..8941469 --- /dev/null +++ b/.changeset/pr-89.md @@ -0,0 +1,5 @@ +--- +"@wdio/browserstack-service": patch +--- + +- Read the `apis` service-URL map from the binary's new `config.sessionData` bucket (SDK-6821 session.config split), with the flat `config.apis` as backward-compat fallback. Single-point change in `setConfig`; verified `npm run build` clean and the vitest suite shows zero new failures vs main (68 pre-existing environmental failures identical on both). From 87342db30596e79eea9ddfc04d1ba6489f44a52f Mon Sep 17 00:00:00 2001 From: Anish Kumar Sinha Date: Mon, 27 Jul 2026 12:53:05 +0530 Subject: [PATCH 03/11] Delete .changeset/pr-89.md --- .changeset/pr-89.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .changeset/pr-89.md diff --git a/.changeset/pr-89.md b/.changeset/pr-89.md deleted file mode 100644 index 8941469..0000000 --- a/.changeset/pr-89.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@wdio/browserstack-service": patch ---- - -- Read the `apis` service-URL map from the binary's new `config.sessionData` bucket (SDK-6821 session.config split), with the flat `config.apis` as backward-compat fallback. Single-point change in `setConfig`; verified `npm run build` clean and the vitest suite shows zero new failures vs main (68 pre-existing environmental failures identical on both). From cc3b998f03188732c74bfb32ea9d42dc1e9ef143 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 07:23:18 +0000 Subject: [PATCH 04/11] chore(changeset): auto-generate from PR template (patch) --- .changeset/pr-89.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pr-89.md diff --git a/.changeset/pr-89.md b/.changeset/pr-89.md new file mode 100644 index 0000000..8941469 --- /dev/null +++ b/.changeset/pr-89.md @@ -0,0 +1,5 @@ +--- +"@wdio/browserstack-service": patch +--- + +- Read the `apis` service-URL map from the binary's new `config.sessionData` bucket (SDK-6821 session.config split), with the flat `config.apis` as backward-compat fallback. Single-point change in `setConfig`; verified `npm run build` clean and the vitest suite shows zero new failures vs main (68 pre-existing environmental failures identical on both). From eebf885126b6ffc1c20b118ddb69f68b132b16fd Mon Sep 17 00:00:00 2001 From: Anish Kumar Sinha Date: Mon, 27 Jul 2026 18:33:54 +0530 Subject: [PATCH 05/11] Delete .changeset/pr-89.md --- .changeset/pr-89.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .changeset/pr-89.md diff --git a/.changeset/pr-89.md b/.changeset/pr-89.md deleted file mode 100644 index 8941469..0000000 --- a/.changeset/pr-89.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@wdio/browserstack-service": patch ---- - -- Read the `apis` service-URL map from the binary's new `config.sessionData` bucket (SDK-6821 session.config split), with the flat `config.apis` as backward-compat fallback. Single-point change in `setConfig`; verified `npm run build` clean and the vitest suite shows zero new failures vs main (68 pre-existing environmental failures identical on both). From b09e0902cde25df91c5ebea621a427bece12b75e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 13:04:06 +0000 Subject: [PATCH 06/11] chore(changeset): auto-generate from PR template (patch) --- .changeset/pr-89.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pr-89.md diff --git a/.changeset/pr-89.md b/.changeset/pr-89.md new file mode 100644 index 0000000..8941469 --- /dev/null +++ b/.changeset/pr-89.md @@ -0,0 +1,5 @@ +--- +"@wdio/browserstack-service": patch +--- + +- Read the `apis` service-URL map from the binary's new `config.sessionData` bucket (SDK-6821 session.config split), with the flat `config.apis` as backward-compat fallback. Single-point change in `setConfig`; verified `npm run build` clean and the vitest suite shows zero new failures vs main (68 pre-existing environmental failures identical on both). From 95088a5c71a6680fed3372d505b4b5062b5800ae Mon Sep 17 00:00:00 2001 From: Anish Kumar Sinha Date: Mon, 27 Jul 2026 18:39:42 +0530 Subject: [PATCH 07/11] Update pr-89.md --- .changeset/pr-89.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.changeset/pr-89.md b/.changeset/pr-89.md index 8941469..8b13789 100644 --- a/.changeset/pr-89.md +++ b/.changeset/pr-89.md @@ -1,5 +1 @@ ---- -"@wdio/browserstack-service": patch ---- -- Read the `apis` service-URL map from the binary's new `config.sessionData` bucket (SDK-6821 session.config split), with the flat `config.apis` as backward-compat fallback. Single-point change in `setConfig`; verified `npm run build` clean and the vitest suite shows zero new failures vs main (68 pre-existing environmental failures identical on both). From 25c1476a94215f93b2bd104b4d06bc71ef3e9e54 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 13:09:52 +0000 Subject: [PATCH 08/11] chore(changeset): auto-generate from PR template (patch) --- .changeset/pr-89.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.changeset/pr-89.md b/.changeset/pr-89.md index 8b13789..8941469 100644 --- a/.changeset/pr-89.md +++ b/.changeset/pr-89.md @@ -1 +1,5 @@ +--- +"@wdio/browserstack-service": patch +--- +- Read the `apis` service-URL map from the binary's new `config.sessionData` bucket (SDK-6821 session.config split), with the flat `config.apis` as backward-compat fallback. Single-point change in `setConfig`; verified `npm run build` clean and the vitest suite shows zero new failures vs main (68 pre-existing environmental failures identical on both). From 7f5d624e4ef1dc19b28e1847f539844f6bc95984 Mon Sep 17 00:00:00 2001 From: Anish Kumar Sinha Date: Mon, 27 Jul 2026 18:40:18 +0530 Subject: [PATCH 09/11] Delete .changeset/pr-89.md --- .changeset/pr-89.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .changeset/pr-89.md diff --git a/.changeset/pr-89.md b/.changeset/pr-89.md deleted file mode 100644 index 8941469..0000000 --- a/.changeset/pr-89.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@wdio/browserstack-service": patch ---- - -- Read the `apis` service-URL map from the binary's new `config.sessionData` bucket (SDK-6821 session.config split), with the flat `config.apis` as backward-compat fallback. Single-point change in `setConfig`; verified `npm run build` clean and the vitest suite shows zero new failures vs main (68 pre-existing environmental failures identical on both). From 74c2682b8eb647b6e209c6fa72c17eaa88460504 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 13:10:30 +0000 Subject: [PATCH 10/11] chore(changeset): auto-generate from PR template (patch) --- .changeset/pr-89.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pr-89.md diff --git a/.changeset/pr-89.md b/.changeset/pr-89.md new file mode 100644 index 0000000..8941469 --- /dev/null +++ b/.changeset/pr-89.md @@ -0,0 +1,5 @@ +--- +"@wdio/browserstack-service": patch +--- + +- Read the `apis` service-URL map from the binary's new `config.sessionData` bucket (SDK-6821 session.config split), with the flat `config.apis` as backward-compat fallback. Single-point change in `setConfig`; verified `npm run build` clean and the vitest suite shows zero new failures vs main (68 pre-existing environmental failures identical on both). From 6c90d8c1cf20ddd803e561118b3e8fbbca49dcce Mon Sep 17 00:00:00 2001 From: Anish Sinha Date: Mon, 27 Jul 2026 19:42:47 +0530 Subject: [PATCH 11/11] test(cli): commit the sessionData apis 3-case matrix (SDK-6821 review) Bucket-only (the Phase-4 shape the flat fallback cannot mask), bucket-beats-stale-flat, and flat-only (old binary) against the real setConfig. Co-Authored-By: Claude Fable 5 --- .../tests/cli/index.test.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/browserstack-service/tests/cli/index.test.ts b/packages/browserstack-service/tests/cli/index.test.ts index b8465df..d4415b8 100644 --- a/packages/browserstack-service/tests/cli/index.test.ts +++ b/packages/browserstack-service/tests/cli/index.test.ts @@ -93,4 +93,30 @@ describe('BrowserstackCLI bootstrap error surfacing', () => { expect(loggerErrorSpy).toHaveBeenCalledWith('[Build] ERROR_ACCESS_DENIED: Access to BrowserStack denied due to incorrect credentials.') }) }) + + // SDK-6821: apis arrives under the sessionData bucket (flat kept for backward + // compat until every SDK migrates). The bucket-only case is the Phase-4 shape — + // the one a broken hoist cannot mask via the flat fallback. + describe('setConfig sessionData apis hoist (SDK-6821)', () => { + const setConfigWith = (config: Record) => + instance.setConfig({ config: JSON.stringify(config) } as any) + + it('resolves apis from sessionData alone (future caps-only echo)', () => { + setConfigWith({ sessionData: { apis: { automate: { api: 'https://api.browserstack.com' } } } }) + expect(instance.config.apis).toEqual({ automate: { api: 'https://api.browserstack.com' } }) + }) + + it('prefers sessionData.apis over a stale flat apis', () => { + setConfigWith({ + apis: { automate: { api: 'https://stale.example' } }, + sessionData: { apis: { automate: { api: 'https://fresh.example' } } } + }) + expect(instance.config.apis).toEqual({ automate: { api: 'https://fresh.example' } }) + }) + + it('keeps the flat apis when no bucket is present (old binary)', () => { + setConfigWith({ apis: { automate: { api: 'https://flat-only.example' } } }) + expect(instance.config.apis).toEqual({ automate: { api: 'https://flat-only.example' } }) + }) + }) })