fix(web_fetch): cap response body before parsing

This commit is contained in:
Peter Steinberger
2026-02-16 01:19:04 +01:00
parent fd3d452f1f
commit 166cf6a3e0
7 changed files with 284 additions and 8 deletions

View File

@@ -486,7 +486,8 @@ async function runPerplexitySearch(params: {
});
if (!res.ok) {
const detail = await readResponseText(res);
const detailResult = await readResponseText(res, { maxBytes: 64_000 });
const detail = detailResult.text;
throw new Error(`Perplexity API error (${res.status}): ${detail || res.statusText}`);
}
@@ -535,7 +536,8 @@ async function runGrokSearch(params: {
});
if (!res.ok) {
const detail = await readResponseText(res);
const detailResult = await readResponseText(res, { maxBytes: 64_000 });
const detail = detailResult.text;
throw new Error(`xAI API error (${res.status}): ${detail || res.statusText}`);
}
@@ -665,7 +667,8 @@ async function runWebSearch(params: {
});
if (!res.ok) {
const detail = await readResponseText(res);
const detailResult = await readResponseText(res, { maxBytes: 64_000 });
const detail = detailResult.text;
throw new Error(`Brave Search API error (${res.status}): ${detail || res.statusText}`);
}