{"record":{"id":"0508cbdd01f57b7e","repo":"Kong/insomnia","slug":"could-not-set-body-without-existing-body-path","errorCode":null,"errorMessage":"Could not set body without existing body path","messagePattern":"Could not set body without existing body path","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/insomnia/src/plugins/context/response.ts","lineNumber":83,"sourceCode":"          try {\n            fs.statSync(response?.bodyPath);\n          } catch (err) {\n            console.warn('Failed to read response body', err.message);\n            return readFailureValue === undefined ? null : readFailureValue;\n          }\n          if (response?.bodyCompression === 'zip') {\n            return fs.createReadStream(response?.bodyPath).pipe(zlib.createGunzip());\n          }\n          return fs.createReadStream(response?.bodyPath);\n        };\n\n        return getResponseBodyStream(response);\n      },\n\n      setBody(body: Buffer) {\n        // Should never happen but just in case it does...\n        if (!response.bodyPath) {\n          throw new Error('Could not set body without existing body path');\n        }\n\n        const fs = require('node:fs');\n        fs.writeFileSync(response.bodyPath, body);\n        response.bytesContent = body.length;\n      },\n\n      getHeader(name: string): string | string[] | null {\n        const headers = response.headers || [];\n        const matchedHeaders = headers.filter(h => h.name.toLowerCase() === name.toLowerCase());\n\n        if (matchedHeaders.length > 1) {\n          return matchedHeaders.map(h => h.value);\n        } else if (matchedHeaders.length === 1) {\n          return matchedHeaders[0].value;\n        }\n        return null;\n      },","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia/src/plugins/context/response.ts#L65-L101","documentation":"Error \"Could not set body without existing body path\" thrown in Kong/insomnia.","triggerScenarios":"Thrown at packages/insomnia/src/plugins/context/response.ts:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d9bb2b0142600f21309832daea3317942d285984","analyzedAt":"2026-08-26T18:04:05.187Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}