Skip to content

[CB-0] [sdk-superfan] Catch only expected errors in the extension example's delete checks - #223

Draft
spicysouvlaki wants to merge 1 commit into
mainfrom
wschmitt/example-extension-delete-check
Draft

spicysouvlaki wants to merge 1 commit into
mainfrom
wschmitt/example-extension-delete-check

Conversation

@spicysouvlaki

@spicysouvlaki spicysouvlaki commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What happened

#180. The example's checks after deleting an extension catch their own AssertionError with except Exception, so any outcome prints "... as expected".

Why

playwright_extensions.py:125-140: the raise AssertionError sits inside the try. On dev, the session check first returned 429 ... max concurrent sessions, which the old code also counts as a pass (measured).

Fix

Catch only the errors the API actually returns, both measured on dev: retrieve raises NotFoundError (404) and sessions.create raises BadRequestError (400, "Extension ID not found").

Tests

  • A throwaway harness (not committed, because examples aren't in the unit suite) stubs the client and runs run(). Before the fix: 3 failed, 1 passed. After: 4 passed. It covers the expected errors, an unexpected success on each check, and a 429.
  • ./scripts/lint: clean. ./scripts/test (py3.9 pydantic v2/v1, py3.14): all pass.
  • Not run: the example end to end. Its proxies=True session returns 402 on the dev plan, and examples/e2e/test_playwright.py doesn't import this example.

Risk and rollout

examples/ is custom code, so this has no Stainless impact and nothing ships.

Fixes #180

🤖 Generated with Claude Code

…n 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 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Extension example catches its own assertions and cannot detect failed deletion

1 participant