Skip to content

Conversation

kallakuripraphul
Copy link

why

Following the quickstart, calling await stagehand.init() can fail with:
UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.
This happens when api_url is unset or set without a scheme (e.g., "api.stagehand.browserbase.com/v1").

what changed

  • Validate api_url in Stagehand.__init__
  • If empty → raise:
    ValueError: api_url is not set. Please set StagehandConfig.api_url or the STAGEHAND_API_URL environment variable.
    
    • If it doesn’t start with http:// or https:// → raise:
      ValueError: Invalid api_url: <value>. Must start with http:// or https://
      
  • Keep existing behavior for valid configs; this just fails earlier
    Relation to fix bug on api_url load from .env #116

Related: #116 . This PR is similar to #116 by catching misconfigurations (missing scheme / empty) before reaching httpx,

@kallakuripraphul kallakuripraphul changed the title Debug/init Validate api_url scheme; fail early with clear errors Aug 15, 2025
@kallakuripraphul kallakuripraphul deleted the debug/init branch August 21, 2025 17:19
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.

1 participant