{"record":{"id":"59d9f64311c91cdd","repo":"Kong/insomnia","slug":"dynamic-typeerror-bodybuffer","errorCode":null,"errorMessage":"[dynamic TypeError(bodyBuffer)]","messagePattern":"\\[dynamic TypeError\\(bodyBuffer\\)\\]","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/insomnia/src/common/templating/local-template-tags.ts","lineNumber":672,"sourceCode":"          console.log('[response tag] Invalid status code ' + response.statusCode);\n          throw new Error('No successful responses for request');\n        }\n\n        if (field !== 'raw' && field !== 'url' && !filter) {\n          throw new Error(`No ${field} filter specified`);\n        }\n\n        const sanitizedFilter = filter.trim();\n        const bodyBuffer = await context.util.models.response.getBodyBuffer(response, '');\n        const match = response.contentType && response.contentType.match(/charset=([\\w-]+)/);\n        const charset = match && match.length >= 2 ? match[1] : 'utf8';\n        if (field === 'url') {\n          return response.url;\n        }\n        if (field === 'raw' && bodyBuffer !== null) {\n          // Sometimes iconv conversion fails so fallback to regular buffer\n          if (typeof bodyBuffer === 'string') {\n            throw new TypeError(bodyBuffer);\n          }\n          try {\n            return context.util.decode(bodyBuffer, charset);\n          } catch (err) {\n            console.warn('[response] Failed to decode body', err);\n            return utf8StringFromBytes(bodyBuffer);\n          }\n        }\n        if (field === 'header') {\n          if (!response.headers.length) {\n            throw new Error('No headers available');\n          }\n          const header = response.headers.find(h => h.name.toLowerCase() === sanitizedFilter.toLowerCase());\n          if (!header) {\n            const names = response.headers.map(c => `\"${c.name}\"`).join(',\\n\\t');\n            throw new Error(`No header with name \"${sanitizedFilter}\".\\nChoices are [\\n\\t${names}\\n]`);\n          }\n          return header.value;","sourceCodeStart":654,"sourceCodeEnd":690,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia/src/common/templating/local-template-tags.ts#L654-L690","documentation":"Error \"[dynamic TypeError(bodyBuffer)]\" thrown in Kong/insomnia.","triggerScenarios":"Thrown at packages/insomnia/src/common/templating/local-template-tags.ts:672 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"}