Skip to content

fix: throw error if BROWSERBASE env is set without API key (fixes #592) #642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2025

Conversation

omlahore
Copy link
Contributor

@omlahore omlahore commented Apr 6, 2025

Fixes #592

why

Previously, the fallback to LOCAL mode was silent, which could be misleading in production. Now, the constructor and getBrowser() both throw informative errors to help developers catch misconfigurations early.

what changed

This PR adds an explicit error when env: "BROWSERBASE" is used without a valid BROWSERBASE_API_KEY.

test plan

Tested with npm run example and verified the error is thrown as expected.

Copy link

changeset-bot bot commented Apr 6, 2025

⚠️ No Changeset found

Latest commit: 7e42d26

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR enforces explicit errors for misconfigured Browserbase environments by throwing informative errors when a BROWSERBASE API key is missing, preventing a silent fallback to LOCAL mode.

  • Updated /lib/index.ts to throw explicit errors in getBrowser() when env is "BROWSERBASE" but API key is absent.
  • Highlights duplicated API key checks, suggesting consolidation for consistency.
  • Improves development feedback by catching misconfigurations early.

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Contributor

@kamath kamath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your contribution! continuing this in #633

@kamath kamath merged commit 743f633 into browserbase:main Apr 9, 2025
1 of 3 checks passed
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.

Stagehand env set to "BROWSERBASE", but API key is undefined—defaults to LOCAL instead of throwing an error
2 participants