Kong/insomnia · error
Failed to parse API spec
Error message
Failed to parse API spec
What it means
Error "Failed to parse API spec" thrown in Kong/insomnia.
Source
Thrown at packages/insomnia/src/common/api-specs.ts:22
contents: Record<string, any> | null;
rawContents: string;
format: 'openapi' | 'swagger' | null;
formatVersion: string | null;
}
export function parseApiSpec(rawDocument: string) {
const result: ParsedApiSpec = {
contents: null,
rawContents: rawDocument,
format: null,
formatVersion: null,
};
// NOTE: JSON is valid YAML so we only need to parse YAML
try {
result.contents = YAML.parse(rawDocument);
} catch {
throw new Error('Failed to parse API spec');
}
if (result.contents) {
if (result.contents.openapi) {
// Check if it's OpenAPI
result.format = 'openapi';
result.formatVersion = result.contents.openapi;
} else if (result.contents.swagger) {
// Check if it's Swagger
result.format = 'swagger';
result.formatVersion = result.contents.swagger;
} else {
// Not sure what format it is
}
}
return result;
}View on GitHub (pinned to d9bb2b0142)
When it happens
Trigger: Thrown at packages/insomnia/src/common/api-specs.ts:22 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of Kong/insomnia@d9bb2b0142 (2026-08-26).
Data as JSON: /api/errors/fe31ce8cc1b97b05.
Report an issue: GitHub.