{"record":{"id":"50871a8d2bc4dcb3","repo":"diegosouzapw/OmniRoute","slug":"openroutercatalog-failed-to-write-cache","errorCode":null,"errorMessage":"[OpenRouterCatalog] Failed to write cache:","messagePattern":"\\[OpenRouterCatalog\\] Failed to write cache:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/catalog/openrouterCatalog.ts","lineNumber":84,"sourceCode":"    if (!fs.existsSync(filePath)) return null;\n    const raw = fs.readFileSync(filePath, \"utf8\");\n    return JSON.parse(raw) as CacheFile;\n  } catch {\n    return null;\n  }\n}\n\n/** Write catalog to disk cache. */\nfunction writeCache(data: CatalogEntry[]): void {\n  const filePath = getCacheFilePath();\n  const cache: CacheFile = {\n    fetchedAt: new Date().toISOString(),\n    data,\n  };\n  try {\n    fs.writeFileSync(filePath, JSON.stringify(cache, null, 2), \"utf8\");\n  } catch (err) {\n    console.warn(\"[OpenRouterCatalog] Failed to write cache:\", err);\n  }\n}\n\n/** Fetch fresh catalog from OpenRouter API. */\nasync function fetchFromAPI(): Promise<CatalogEntry[]> {\n  const res = await fetch(OPENROUTER_API_URL, {\n    headers: {\n      \"User-Agent\": \"OmniRoute/2.0\",\n      Accept: \"application/json\",\n    },\n    signal: AbortSignal.timeout(15_000),\n  });\n\n  if (!res.ok) {\n    throw new Error(`OpenRouter API returned ${res.status}: ${res.statusText}`);\n  }\n\n  const json = (await res.json()) as { data?: CatalogEntry[] };","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/catalog/openrouterCatalog.ts#L66-L102","documentation":"Error \"[OpenRouterCatalog] Failed to write cache:\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/catalog/openrouterCatalog.ts:84 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":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}