You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Client creates zones in __aenter__ even when no zone is used; accounts without a payment method fail with 403 before any scraper call #57
SDK: brightdata-sdk 2.5.2 (latest on PyPI), Python 3.12, macOS. Account without a payment method (a new free account).
Steps to reproduce
pip install brightdata-sdk==2.5.2
export BRIGHTDATA_API_TOKEN=YOUR_API_KEY # a token from an account with no payment method
python - <<'PY'from brightdata import SyncBrightDataClientwith SyncBrightDataClient() as client: # every argument at its default print(client.search.instagram.profiles("nasa").data[0]["followers"])PY
Actual
The client never gets to the scraper call. Entering the context manager fails:
Failed to create zone 'sdk_unlocker' due to insufficient permissions
❌ ZONE CREATION BLOCKED: API token lacks required permissions
Error: Forbidden (403): {"msg":"A payment method is required for this zone action. Please add a payment method and try again.","err_id":"payment_method_required"}
Fix: Update your token permissions at https://brightdata.com/cp/setting/users
AuthenticationError: Forbidden (403): {"msg":"A payment method is required for this zone action. Please add a payment method and try again.","err_id":"payment_method_required"}
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x10516cc50>
Expected
A scraper call needs no zone. The client should not try to create sdk_unlocker and sdk_serp unless Web Unlocker or SERP is actually used. The _ensure_zones docstring already describes that behaviour: "This is called automatically before the first API request." In practice it is called unconditionally from __aenter__ (brightdata/client.py, await self._ensure_zones() right after the optional token validation), so every free account fails on the first with block, before any request.
Three smaller things in the same path:
The printed advice, "API token lacks required permissions ... Update your token permissions", is wrong for this error. The API says a payment method is missing, not a permission.
When __aenter__ raises, engine.__aexit__ is not called, hence the "Unclosed client session" warning.
auto_create_zones defaults to True. Defaulting to False, or creating lazily on first Web Unlocker / SERP use, would remove the failure for everyone who only uses scrapers.
Activity