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

Error "Could not set body without existing body path" thrown in Kong/insomnia.

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)

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.