bump @browserbasehq/sdk to ^2.7.0, make projectId optional#1765
bump @browserbasehq/sdk to ^2.7.0, make projectId optional#1765derekmeegan wants to merge 1 commit intomainfrom
Conversation
SDK v2.7.0 makes projectId optional for session creation. Update all references to treat projectId as optional rather than required. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
There was a problem hiding this comment.
1 issue found across 7 files
Confidence score: 3/5
- Validation rule relaxed in
packages/server/src/routes/v1/sessions/start.tswithout the required integration test underpackages/server/test, which could allow a breaking API behavior change to slip through. - Given the 7/10 severity and concrete API-contract impact, there’s some regression risk despite being a single change.
- Pay close attention to
packages/server/src/routes/v1/sessions/start.ts- relaxed validation needs integration coverage inpackages/server/test.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/server/src/routes/v1/sessions/start.ts">
<violation number="1" location="packages/server/src/routes/v1/sessions/start.ts:114">
P1: Custom agent: **Any breaking changes to Stagehand REST API client / server implementation must be covered by an integration test under packages/server/test**
This change relaxes a server-side validation rule (making `x-bb-project-id` optional for browserbase sessions), which alters the API contract. There is no integration test under `packages/server/test/` that covers this new behavior — e.g., verifying that a request without `x-bb-project-id` is now accepted, and that a request without `x-bb-api-key` still returns the updated error message. Add integration tests to validate both the happy path (missing `x-bb-project-id` succeeds) and the error path (missing `x-bb-api-key` returns `"Missing required x-bb-api-key header for browserbase sessions"`).
(Based on your team's feedback about adding unit tests for new behavior.) [FEEDBACK_USED]</violation>
</file>
Architecture diagram
sequenceDiagram
participant User as User / Client
participant Server as Stagehand Server
participant Core as V3 Core Logic
participant APIClient as Stagehand API Client
participant BBSDK as @browserbasehq/sdk
participant BBAPI as Browserbase API
Note over User,BBAPI: Session Initialization Flow
User->>Server: POST /sessions/start
Note right of Server: Headers: x-bb-api-key, [x-bb-project-id]
Server->>Server: Validate Credentials
alt API Key Missing
Server-->>User: 400 Error (Missing x-bb-api-key)
else API Key Present
Server->>Core: init()
end
Core->>Core: requireBrowserbaseCreds()
Note right of Core: Reads from options or ENV
alt CHANGED: Project ID Check
Note over Core: Only BROWSERBASE_API_KEY is strictly required
end
Core->>BBSDK: NEW: createSession({ projectId? })
BBSDK->>BBAPI: Create Remote Browser Session
BBAPI-->>BBSDK: sessionId, proxyUrl
BBSDK-->>Core: Session Metadata
Note over Core,BBAPI: Runtime API Interaction
Core->>APIClient: Execute Action (e.g., act/observe)
APIClient->>APIClient: Build Request Headers
Note right of APIClient: Always include x-bb-api-key
opt CHANGED: Project ID exists
APIClient->>APIClient: NEW: Add x-bb-project-id to headers
end
APIClient->>BBAPI: Request with conditional headers
BBAPI-->>APIClient: Response
APIClient-->>Core: Data
Core-->>User: Result (Streaming/JSON)
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| bbProjectId = getOptionalHeader(request, "x-bb-project-id"); | ||
|
|
||
| if (!bbApiKey || !bbProjectId) { | ||
| if (!bbApiKey) { |
There was a problem hiding this comment.
P1: Custom agent: Any breaking changes to Stagehand REST API client / server implementation must be covered by an integration test under packages/server/test
This change relaxes a server-side validation rule (making x-bb-project-id optional for browserbase sessions), which alters the API contract. There is no integration test under packages/server/test/ that covers this new behavior — e.g., verifying that a request without x-bb-project-id is now accepted, and that a request without x-bb-api-key still returns the updated error message. Add integration tests to validate both the happy path (missing x-bb-project-id succeeds) and the error path (missing x-bb-api-key returns "Missing required x-bb-api-key header for browserbase sessions").
(Based on your team's feedback about adding unit tests for new behavior.)
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/server/src/routes/v1/sessions/start.ts, line 114:
<comment>This change relaxes a server-side validation rule (making `x-bb-project-id` optional for browserbase sessions), which alters the API contract. There is no integration test under `packages/server/test/` that covers this new behavior — e.g., verifying that a request without `x-bb-project-id` is now accepted, and that a request without `x-bb-api-key` still returns the updated error message. Add integration tests to validate both the happy path (missing `x-bb-project-id` succeeds) and the error path (missing `x-bb-api-key` returns `"Missing required x-bb-api-key header for browserbase sessions"`).
(Based on your team's feedback about adding unit tests for new behavior.) </comment>
<file context>
@@ -111,10 +111,10 @@ const startRouteHandler: RouteHandler = withErrorHandling(
bbProjectId = getOptionalHeader(request, "x-bb-project-id");
- if (!bbApiKey || !bbProjectId) {
+ if (!bbApiKey) {
return error(
reply,
</file context>
Greptile SummaryUpdates Issues found:
Confidence Score: 2/5
Important Files Changed
Last reviewed commit: 02567d4 |
Additional Comments (3)
|
why
SDK v2.7.0 makes projectId optional for session creation. Update all references to treat projectId as optional rather than required.
what changed
new browserbase sdk version and optional project id
test plan