Kong/insomnia · error · Error
Could not set body without existing body path
Error message
Could not set body without existing body path
What it means
Guard in the plugin response context's setBody: attempting to replace the response body when no bodyPath exists on the stored response (nothing was written to disk), so there is no file to overwrite — a should-never-happen internal consistency check.
Solutions
- Ensure the response has been received and streamed to disk before mutating the body
- Report as an internal bug if triggered during normal plugin usage
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at packages/insomnia/src/plugins/context/response.ts:83 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Kong/insomnia@d9bb2b0142 (2026-08-26).
Data as JSON: /api/errors/0508cbdd01f57b7e.
Report an issue: GitHub.
Appendix: source
Thrown at packages/insomnia/src/plugins/context/response.ts:83
try {
fs.statSync(response?.bodyPath);
} catch (err) {
console.warn('Failed to read response body', err.message);
return readFailureValue === undefined ? null : readFailureValue;
}
if (response?.bodyCompression === 'zip') {
return fs.createReadStream(response?.bodyPath).pipe(zlib.createGunzip());
}
return fs.createReadStream(response?.bodyPath);
};
return getResponseBodyStream(response);
},
setBody(body: Buffer) {
// Should never happen but just in case it does...
if (!response.bodyPath) {
throw new Error('Could not set body without existing body path');
}
const fs = require('node:fs');
fs.writeFileSync(response.bodyPath, body);
response.bytesContent = body.length;
},
getHeader(name: string): string | string[] | null {
const headers = response.headers || [];
const matchedHeaders = headers.filter(h => h.name.toLowerCase() === name.toLowerCase());
if (matchedHeaders.length > 1) {
return matchedHeaders.map(h => h.value);
} else if (matchedHeaders.length === 1) {
return matchedHeaders[0].value;
}
return null;
},View on GitHub (pinned to d9bb2b0142)