Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#180 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
typescript
領域
api

調査の方向性

core.ts と core.mjs の issue に示されている defaultHeaders のロジックから始め、contexts.delete() リクエストおよび関連する extensions.delete() のバグと比較します。ボディのない DELETE が JSON Content-Type ヘッダーを受け取らなくなり、contexts.delete() が HTTP 204 または 200 で正常に完了すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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)
主要言語
TypeScript
スター
64
フォーク
17
平均マージ
13分
マージ済み PR(30日)
4

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

browserbase/sdk-node のほかの issue

browserbase/sdk-node の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。