Kong/insomnia · error · InsoError

Failed to read

Error message

Failed to read "${filePath}"

What it means

Filesystem read failure while locating a Spectral ruleset for linting: getRuleSetFileFromFolderByFilename could not read the directory containing the specification file (permissions, missing folder, or I/O error) when searching for a file starting with '.spectral'.

Solutions

  1. Verify the spec file path exists and its directory is readable
  2. Check directory permissions
  3. Pass an explicit ruleset instead of relying on folder discovery
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/insomnia-inso/src/commands/lint-specification.ts:80 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/88647ea98f01651a. Report an issue: GitHub.

Appendix: source

Thrown at packages/insomnia-inso/src/commands/lint-specification.ts:80

export const safeRefResolver = new Resolver({
  resolvers: {
    http: safeHttpResolver,
    https: safeHttpResolver,
  },
});

export const getRuleSetFileFromFolderByFilename = async (filePath: string) => {
  try {
    const filesInSpecFolder = await fs.promises.readdir(path.dirname(filePath));
    const rulesetFileName = filesInSpecFolder.find(file => file.startsWith('.spectral'));
    if (rulesetFileName) {
      logger.trace(`Loading ruleset from \`${rulesetFileName}\``);
      return path.resolve(path.dirname(filePath), rulesetFileName);
    }
    logger.info(`Using ruleset: oas, see ${oas.documentationUrl}`);
    return;
  } catch (error) {
    throw new InsoError(`Failed to read "${filePath}"`, error);
  }
};
export async function lintSpecification({
  specContent,
  rulesetFileName,
}: {
  specContent: string;
  rulesetFileName?: string;
}) {
  const spectral = new Spectral({ resolver: safeRefResolver });
  // Use custom ruleset if present
  let ruleset = oas;
  try {
    if (rulesetFileName) {
      // Step 1: flatten local extends and validate remote URLs (SSRF + disallowed keys).
      const bundled = await bundleSpectralRuleset(rulesetFileName);
      // Step 2: fetch + fully inline remote extends so bundleAndLoadRuleset has nothing to fetch,
      // closing the validate-then-use race.

View on GitHub (pinned to d9bb2b0142)