{"record":{"id":"d9b2840a374995f9","repo":"Kong/insomnia","slug":"invalid-projectid-projectid","errorCode":null,"errorMessage":"Invalid projectId \"${projectId}\"","messagePattern":"Invalid projectId \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/insomnia/src/main/spectral-ruleset-cache.ts","lineNumber":18,"sourceCode":"import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { app } from 'electron';\n\nimport { compileSpectralRulesetFromContent } from '~/main/bundle-spectral-ruleset';\n\n// In-memory cache of the last written ruleset content hash for each project ID.\n// 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.\n// 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).\nconst lastWrittenHash = new Map<string, string>();\n\n// Derives the on-disk path where the compiled ruleset for a project is written.\n// Keyed by projectId so different projects never collide.\nexport function compiledRulesetPathFor(projectId: string): string {\n  if (!projectId || !/^proj_[a-z0-9_]+$/i.test(projectId)) {\n    throw new Error(`Invalid projectId \"${projectId}\"`);\n  }\n  const base = process.env['INSOMNIA_DATA_PATH'] || app.getPath('userData');\n  return path.join(base, 'projects', projectId, '.spectral.yaml');\n}\n\n// Compiles raw ruleset content and writes the flattened result to the project's compiled path.\n// Skips recompilation if the content hasn't changed since the last write (keyed by projectId)\n// and the compiled file still exists on disk. Throws if compilation fails.\nexport async function writeCompiledRuleset(\n  projectId: string,\n  rulesetContent: string,\n): Promise<{\n  compiledPath: string;\n}> {\n  const compiledPath = compiledRulesetPathFor(projectId);\n  const hash = createHash('sha256').update(rulesetContent).digest('hex');\n  if (lastWrittenHash.get(projectId) === hash) {\n    try {","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia/src/main/spectral-ruleset-cache.ts#L1-L36","documentation":"Error \"Invalid projectId \"${projectId}\"\" thrown in Kong/insomnia.","triggerScenarios":"Thrown at packages/insomnia/src/main/spectral-ruleset-cache.ts:18 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d9bb2b0142600f21309832daea3317942d285984","analyzedAt":"2026-08-26T18:04:05.187Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}