{"record":{"id":"6eb6e790b37057a8","repo":"overleaf/overleaf","slug":"notfounderror-6eb6e7","errorCode":null,"errorMessage":"NotFoundError","messagePattern":"NotFoundError","errorType":"http","errorClass":"NotFoundError","httpStatus":404,"severity":"warning","filePath":"services/web/app/src/Features/Compile/ClsiCacheHandler.mjs","lineNumber":274,"sourceCode":") {\n  const url = new URL(\n    `/project/${projectId}/user/${userId}/import-from`,\n    Settings.apis.clsiCache.instances.find(i => i.shard === shard).url\n  )\n  try {\n    await fetchNothing(url, {\n      method: 'POST',\n      json: {\n        sourceProjectId,\n        lastUpdated,\n        templateVersionId,\n        imageName,\n      },\n      signal,\n    })\n  } catch (err) {\n    if (err instanceof RequestFailedError && err.response.status === 404) {\n      throw new NotFoundError()\n    }\n    throw err\n  }\n}\n\n/**\n * Populate the clsi-cache for a template using a submission build\n *\n * @param clsiCacheShard\n * @param submissionId\n * @param editorBuildId\n * @param templateVersionId\n * @param imageName\n * @return {Promise<void>}\n */\nasync function exportSubmissionAsTemplate(\n  clsiCacheShard,\n  submissionId,","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/overleaf/overleaf/blob/28ad3b03b71cb4311decdcb55c36b33ec10d72db/services/web/app/src/Features/Compile/ClsiCacheHandler.mjs#L256-L292","documentation":"prepareCacheSource calls a clsi-cache HTTP endpoint and converts a 404 RequestFailedError into a plain NotFoundError, meaning the requested cache resource (project/user entry) does not exist on the cache service. Any other error is rethrown unchanged.","triggerScenarios":"The clsi-cache responds HTTP 404 to the prepare/populate request — the project has no cache entry (never compiled there) or was evicted before the call.","commonSituations":"Cache instance restarted or evicted the project; wrong shard routing so the populated entry lives on a different cache node; race where cache TTL expires between populate and prepare.","solutions":["Compile on the target cache instance first so an entry exists","Verify shard routing configuration so requests hit the cache node that holds the data","Check clsi-cache eviction/TTL settings if entries vanish too quickly","Handle the NotFoundError upstream by falling back to a full compile"],"exampleFix":"// before\nawait ClsiCacheHandler.promises.prepareCacheSource(projectId, userId, source)\n// after\ntry {\n  await ClsiCacheHandler.promises.prepareCacheSource(projectId, userId, source)\n} catch (err) {\n  if (err instanceof NotFoundError) {\n    return prepareFromClsiInstead(projectId, userId)\n  }\n  throw err\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await ClsiCacheHandler.promises.prepareCacheSource(projectId, userId, source)\n} catch (err) {\n  if (err instanceof NotFoundError) {\n    return fallbackToFullCompile(projectId, userId)\n  }\n  throw err\n}","preventionTips":["Ensure the project was compiled on the target cache instance before preparing a source","Verify shard routing so lookups hit the node holding the data","Set cache TTLs longer than the prepare/populate interval"],"tags":["http-404","cache","not-found","clsi-cache"],"backgroundTag":"http-404-not-found","analyzedSha":"28ad3b03b71cb4311decdcb55c36b33ec10d72db","analyzedAt":"2026-09-03T02:10:22.807Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}