Kong/insomnia · error
Failed to parse API spec
Error message
Failed to parse API spec
What it means
Thrown by parseApiSpec when YAML.parse of the raw spec document throws — the spec content is neither valid YAML nor valid JSON (JSON is a YAML subset), so it cannot be analyzed as an OpenAPI/Swagger document.
Solutions
- Fix YAML syntax errors (indentation, tabs, unquoted special chars)
- Paste the spec into a YAML validator
- If JSON, validate it with a JSON linter
Defensive patterns
Strategy: validation
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.
Appendix: 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)