Kong/insomnia · error · Error

contentInfo: mime type in header Content-Type is invalid

Error message

contentInfo: mime type in header Content-Type is invalid

What it means

Validation branch in Response.contentInfo: the first directive of the Content-Type header (the MIME type) failed validation — empty or not a recognizable mime type — so the response's content info cannot be computed from the header.

Solutions

  1. Fix the server to send a well-formed Content-Type like application/json
  2. Remove or correct malformed Content-Type headers in the script
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/insomnia-scripting-environment/src/objects/response.ts:111 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/5e8b872c0e3771b3. Report an issue: GitHub.

Appendix: source

Thrown at packages/insomnia-scripting-environment/src/objects/response.ts:111

    return '_kind' in obj && obj._kind === 'Response';
  }

  contentInfo(): ResponseContentInfo {
    const mimeInfo = {
      mimeType: 'application/octet-stream',
      mimeFormat: '', // TODO: it's definition is unknown
      charset: 'utf8',
    };

    const contentType = this.headers.find(header => header.key === 'Content-Type');
    if (contentType) {
      const directives = contentType.valueOf().split('; ');
      if (directives.length === 0) {
        throw new Error('contentInfo: header Content-Type value is blank');
      } else {
        const mimeType = directives[0];
        if (!mimeType) {
          throw new Error('contentInfo: mime type in header Content-Type is invalid');
        }
        mimeInfo.mimeType = mimeType;
        directives.forEach(dir => {
          if (dir.startsWith('charset')) {
            mimeInfo.charset = dir.slice(dir.indexOf('=') + 1);
          }
        });
      }
    }

    const fileInfo = {
      extension: '',
      name: 'unknown',
    };

    const contentDisposition = this.headers.find(header => header.key === 'Content-Disposition');
    if (contentDisposition) {
      const directives = contentDisposition.valueOf().split('; ');

View on GitHub (pinned to d9bb2b0142)