From ddaf28709a98aa15eb13a53015baee4194188846 Mon Sep 17 00:00:00 2001 From: William Schmitt Date: Mon, 16 Nov 2026 13:27:37 -0800 Subject: [PATCH] fix(examples): only treat the expected API errors as deleted-extension proof Both post-delete checks raised AssertionError inside a `try` whose `except Exception` caught it, so an unexpected success printed "failed ... as expected". Any other failure did too: on the dev API the session-create check first hit `RateLimitError 429 ... max concurrent sessions` and would have "passed". Measured on api.dev.browserbase.com after deleting an extension: - `extensions.retrieve(id)` -> NotFoundError 404 - `sessions.create(extension_id=id)` -> BadRequestError 400 "Extension ID not found" Catch exactly those. The AssertionError and any other error now propagate. examples/ is custom code (not generated). The example is not wired into examples/e2e/test_playwright.py, and it cannot run end to end on the dev key (it creates a `proxies=True` session, which that plan rejects with 402), so the check was exercised with a throwaway harness that stubs the client: before 3 failed / 1 passed, after 4 passed. Co-Authored-By: Claude Opus 5.5 --- examples/playwright_extensions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/playwright_extensions.py b/examples/playwright_extensions.py index b7f6332c..c12ee155 100644 --- a/examples/playwright_extensions.py +++ b/examples/playwright_extensions.py @@ -10,6 +10,7 @@ BROWSERBASE_PROJECT_ID, bb, ) +from browserbase import NotFoundError, BadRequestError from browserbase.types import Extension, SessionCreateResponse PATH_TO_EXTENSION = Path.cwd() / "examples" / "packages" / "extensions" / "browserbase-test" @@ -125,7 +126,7 @@ def run(playwright: Playwright) -> None: try: get_extension(extension_id) raise AssertionError("Expected to fail when retrieving deleted extension") - except Exception as e: + except NotFoundError as e: print(f"Failed to get deleted extension as expected: {str(e)}") try: @@ -134,7 +135,7 @@ def run(playwright: Playwright) -> None: extension_id=extension_id, ) raise AssertionError("Expected to fail when creating session with deleted extension") - except Exception as e: + except BadRequestError as e: print(f"Failed to create session with deleted extension as expected: {str(e)}")