Kong/insomnia · error

Invalid projectId "${projectId}"

Error message

Invalid projectId "${projectId}"

What it means

Error "Invalid projectId "${projectId}"" thrown in Kong/insomnia.

Source

Thrown at packages/insomnia/src/main/spectral-ruleset-cache.ts:18

import { createHash } from 'node:crypto';
import fs from 'node:fs';
import path from 'node:path';

import { app } from 'electron';

import { compileSpectralRulesetFromContent } from '~/main/bundle-spectral-ruleset';

// In-memory cache of the last written ruleset content hash for each project ID.
// We need this to avoid expensive recompilation and disk writes when a user relints their spec and the ruleset content hasn't changed since the last compilation.
// TODO: If a remote URL entry updates content after a user has already compiled a ruleset that references it, provide a UI mechanism to invalidate their cache (e.g. "Recompile ruleset" button in the spec view).
const lastWrittenHash = new Map<string, string>();

// Derives the on-disk path where the compiled ruleset for a project is written.
// Keyed by projectId so different projects never collide.
export function compiledRulesetPathFor(projectId: string): string {
  if (!projectId || !/^proj_[a-z0-9_]+$/i.test(projectId)) {
    throw new Error(`Invalid projectId "${projectId}"`);
  }
  const base = process.env['INSOMNIA_DATA_PATH'] || app.getPath('userData');
  return path.join(base, 'projects', projectId, '.spectral.yaml');
}

// Compiles raw ruleset content and writes the flattened result to the project's compiled path.
// Skips recompilation if the content hasn't changed since the last write (keyed by projectId)
// and the compiled file still exists on disk. Throws if compilation fails.
export async function writeCompiledRuleset(
  projectId: string,
  rulesetContent: string,
): Promise<{
  compiledPath: string;
}> {
  const compiledPath = compiledRulesetPathFor(projectId);
  const hash = createHash('sha256').update(rulesetContent).digest('hex');
  if (lastWrittenHash.get(projectId) === hash) {
    try {

View on GitHub (pinned to d9bb2b0142)

When it happens

Trigger: Thrown at packages/insomnia/src/main/spectral-ruleset-cache.ts:18 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/d9b2840a374995f9. Report an issue: GitHub.