[Bug] contexts.delete() fails with 400 — same Content-Type issue as extensions.delete() (#169)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- api
Research direction
Start in core.ts and core.mjs at the defaultHeaders logic shown in the issue, then compare it with the contexts.delete() request and the related extensions.delete() bug. Done means a bodyless DELETE no longer receives the JSON Content-Type header and contexts.delete() completes successfully with HTTP 204 or 200.
Written by the indexing model from the issue text.
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)
- Dominant language
- TypeScript
- Stars
- 64
- Forks
- 17
- Avg merge
- 13m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from browserbase/sdk-node
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
browserbase/sdk-node#202 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
browserbase/sdk-node#197 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
browserbase/sdk-node#193 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 66/100
browserbase/sdk-node#218 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
browserbase/sdk-node#214 ·
All issues in browserbase/sdk-node
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
mksglu/context-mode#1200 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
anthropics/claude-code#96687 ·
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
AOSSIE-Org/DebateAI#582 · 2 comments ·