Kong/insomnia · error

CSV file must contain at least two rows with first row as…

Error message

CSV file must contain at least two rows with first row as variable names

What it means

Thrown when a CSV iteration-data file has fewer than two rows after normalizing line breaks. The first row supplies variable names and subsequent rows supply values, so a single-row (header-only) or empty CSV fails this minimum-shape validation in getListFromFileOrUrl.

Solutions

  1. Add a header row of variable names as the first line
  2. Add at least one data row beneath the header
  3. Ensure the file uses real line breaks so rows are split correctly
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/insomnia-inso/src/cli.ts:248 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/48146713fb7c7bbb. Report an issue: GitHub.

Appendix: source

Thrown at packages/insomnia-inso/src/cli.ts:248

    }
  } else if (fileType === 'csv') {
    // Replace CRLF (Windows line break) and CR (Mac link break) with \n, then split into csv arrays
    const csvRows = content
      .replace(/\r\n|\r/g, '\n')
      .split('\n')
      .map(row => row.split(','));
    // at least 2 rows required for csv
    if (csvRows.length > 1) {
      const csvHeaders = csvRows[0];
      const csvContentRows = csvRows.slice(1);
      return csvContentRows.map(contentRow =>
        csvHeaders.reduce((acc: Record<string, any>, cur, idx) => {
          acc[cur] = contentRow[idx] ?? '';
          return acc;
        }, {}),
      );
    }
    throw new Error('CSV file must contain at least two rows with first row as variable names');
  }
  throw new Error(`Uploaded file is unsupported ${fileType}`);
};

const transformIterationDataToEnvironmentList = (list: Record<string, string>[]): UserUploadEnvironment[] => {
  return list?.map(data => {
    const orderedJson = orderedJSON.parse<Record<string, any>>(
      JSON.stringify(data || []),
      JSON_ORDER_PREFIX,
      JSON_ORDER_SEPARATOR,
    );
    return {
      name: 'User Upload',
      data: orderedJson.object,
      dataPropertyOrder: orderedJson.map || null,
    };
  });
};

View on GitHub (pinned to d9bb2b0142)