From 26bc77ce564b353d027df4ede13999bd2cd93461 Mon Sep 17 00:00:00 2001 From: Abel Yagubyan Date: Thu, 22 Oct 2026 14:20:37 -0400 Subject: [PATCH] fix(browser): keep refresh guidance for a missing CDP target (#6340) Co-authored-by: Abelo9996 --- src/browser/CdpAuthorizedTarget.ts | 2 ++ .../cdpBrowserProvider.discovery_authorization.test.ts | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/browser/CdpAuthorizedTarget.ts b/src/browser/CdpAuthorizedTarget.ts index af0f7cf4ac..95a2449a3a 100644 --- a/src/browser/CdpAuthorizedTarget.ts +++ b/src/browser/CdpAuthorizedTarget.ts @@ -21,6 +21,8 @@ export const authorizeCdpTarget = ( if (target === undefined) throw new BrowserObservationError(operation, "target_not_found", { detail: `Target ${input.target_id} was not found at the selected endpoint.`, + remediationAction: + "Refresh target discovery for that endpoint and retry with a returned target ID.", }); const origin = sanitizeBrowserUrl(target.url).origin; if ( diff --git a/tests/boundary/browser/cdpBrowserProvider.discovery_authorization.test.ts b/tests/boundary/browser/cdpBrowserProvider.discovery_authorization.test.ts index 653abeec9c..98a8ab55c1 100644 --- a/tests/boundary/browser/cdpBrowserProvider.discovery_authorization.test.ts +++ b/tests/boundary/browser/cdpBrowserProvider.discovery_authorization.test.ts @@ -415,16 +415,18 @@ describe("CdpBrowserProvider: target selection detail", () => { "missing", "target_not_found", "Target missing was not found at the selected endpoint.", + "Refresh target discovery for that endpoint and retry with a returned target ID.", ], [ "disallowed-page", "target_not_allowed", "Target disallowed-page must be an HTTP(S) page in the selected origin scope.", + "Target disallowed-page must be an HTTP(S) page in the selected origin scope.", ], ] as const; const inspected = new Map(); for (const [operation, run] of operations) - for (const [targetId, reason, detail] of selections) { + for (const [targetId, reason, detail, remediation] of selections) { const result = await run({ cdp_endpoint: browser.endpoint, allowed_origins: [browser.allowedOrigin], @@ -437,6 +439,7 @@ describe("CdpBrowserProvider: target selection detail", () => { expect(projected).toMatchObject({ code: "target_unavailable", message: detail, + remediation: { action: remediation }, }); // Only the attributed operation differs from the inspect projection. if (operation === "inspect_web_page")