-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Describe the bug
bb.contexts.delete(id) fails with:
400 Body cannot be empty when content-type is set to 'application/json'
This is the same root cause as #169 (extensions.delete()). The SDK's defaultHeaders in core.ts sets Content-Type: application/json on all non-GET/HEAD methods, including DELETE — which sends no request body.
// core.mjs:140
...(['head', 'get'].includes(opts.method) ? {} : { 'Content-Type': 'application/json' }),DELETE should be excluded here alongside get and head.
Steps to reproduce
import Browserbase from "@browserbasehq/sdk";
const bb = new Browserbase({ apiKey: process.env.BROWSERBASE_API_KEY });
// Create a context
const ctx = await bb.contexts.create({
projectId: process.env.BROWSERBASE_PROJECT_ID,
});
// Try to delete it — fails
await bb.contexts.delete(ctx.id);Expected behavior
Context is deleted successfully (HTTP 204 or 200).
Actual behavior
Throws BadRequestError: 400 Body cannot be empty when content-type is set to 'application/json'.
Attempting to override the header with { headers: { 'Content-Type': '' } } results in a different error: 415 Unsupported Media Type.
Workaround
Use a direct HTTP call (e.g., axios or fetch) that doesn't set Content-Type on bodyless DELETE:
import axios from "axios";
await axios.delete(
`https://api.browserbase.com/v1/contexts/${ctx.id}`,
{ headers: { "x-bb-api-key": process.env.BROWSERBASE_API_KEY } },
);Suggested fix
In core.ts / core.mjs, exclude delete from the Content-Type default:
...(['head', 'get', 'delete'].includes(opts.method) ? {} : { 'Content-Type': 'application/json' }),Environment
@browserbasehq/sdk: latest (installed 2026-03-15)- Node.js: v22.21.1
- OS: macOS (Darwin 25.2.0)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels