Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug] contexts.delete() fails with 400 — same Content-Type issue as extensions.delete() (#169)

Open Beginner friendly
#180 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from browserbase/sdk-node

All issues in browserbase/sdk-node

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.