Kong/insomnia · error

Failed to read directory

Error message

Failed to read directory: ${err}

What it means

IPC readDir handler wrapper: fs.promises.readdir (or the subsequent statSync classification) threw while listing the requested directory — missing folder, permission denied, or I/O error. The underlying error is interpolated.

Solutions

  1. Verify the directory path exists and is readable
  2. Check filesystem permissions on the path
  3. Pick the folder again via the directory picker
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/insomnia/src/main/ipc/main.ts:145 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/bcf55a7f15195a6b. Report an issue: GitHub.

Appendix: source

Thrown at packages/insomnia/src/main/ipc/main.ts:145

  return sanitizedConfig;
};

const readDir = async (_: unknown, options: { path: string }) => {
  try {
    const files = await fs.promises.readdir(options.path);
    return files
      .map(file => {
        const filePath = path.join(options.path, file);
        return {
          type: fs.statSync(filePath).isDirectory() ? 'directory' : fs.statSync(filePath).isFile() ? 'file' : 'other',
          name: file,
          path: filePath,
        };
      })
      .filter(file => file.type !== 'other');
  } catch (err) {
    throw new Error(`Failed to read directory: ${err}`);
  }
};

const writeResponseBodyToFile = async (
  _: unknown,
  options: { sourcePath: string; destinationPath: string; bodyCompression?: 'zip' | null },
) => {
  // Validate sourcePath is within the expected responses directory to prevent a
  // compromised renderer from using this handler to read arbitrary files on disk.
  const userdataDirectory = process.env.INSOMNIA_DATA_PATH || app.getPath('userData');
  const allowedResponsesDir = path.join(userdataDirectory, 'responses');
  const resolvedSource = path.resolve(options.sourcePath);
  if (!resolvedSource.startsWith(allowedResponsesDir + path.sep) || !resolvedSource.endsWith('.response')) {
    throw new Error(
      'writeResponseBodyToFile: sourcePath is outside the allowed responses directory or does not end in .response',
    );
  }

View on GitHub (pinned to d9bb2b0142)