[Bug] contexts.delete() fails with 400 — same Content-Type issue as extensions.delete() (#169)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
- Lĩnh vực
- api
Hướng nghiên cứu
Bắt đầu trong core.ts và core.mjs với logic defaultHeaders được hiển thị trong issue, sau đó so sánh logic này với request contexts.delete() và bug liên quan của extensions.delete(). Hoàn thành khi một DELETE không có body không còn nhận header Content-Type JSON và contexts.delete() hoàn tất thành công với HTTP 204 hoặc 200.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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)
- Ngôn ngữ chính
- TypeScript
- Star
- 64
- Fork
- 17
- Merge trung bình
- 13 phút
- Pull request đã merge (30 ngày)
- 4
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của browserbase/sdk-node
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
browserbase/sdk-node#202 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
browserbase/sdk-node#197 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
browserbase/sdk-node#193 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 66/100
browserbase/sdk-node#218 · 2 bình luận ·
-
SessionCreateParams.api_timeout is the only snake_case param in the SDK — should be apiTimeout Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
browserbase/sdk-node#214 ·
Tất cả issue của browserbase/sdk-node
Issue tương tự
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Crush Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
ElementsProject/cln-application#167 · 1 bình luận · 1 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Quantco/pnpm-licenses#17 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100