{"record":{"id":"3a9dcad868b241b1","repo":"spring-projects/spring-ai","slug":"cached-content-not-found","errorCode":null,"errorMessage":"Cached content not found: ","messagePattern":"Cached content not found: ","errorType":"exception","errorClass":"CachedContentException","httpStatus":null,"severity":"error","filePath":"models/spring-ai-google-genai/src/main/java/org/springframework/ai/google/genai/cache/GoogleGenAiCachedContentService.java","lineNumber":387,"sourceCode":"\t\t\treturn CompletableFuture.completedFuture(false);\n\t\t}\n\t}\n\n\t// Utility methods\n\n\t/**\n\t * Extends the TTL of cached content by the specified duration.\n\t * @param name the cached content name\n\t * @param additionalTtl the additional TTL to add\n\t * @return the updated cached content\n\t */\n\tpublic @Nullable GoogleGenAiCachedContent extendTtl(String name, Duration additionalTtl) {\n\t\tAssert.hasText(name, \"Name must not be empty\");\n\t\tAssert.notNull(additionalTtl, \"Additional TTL must not be null\");\n\n\t\tGoogleGenAiCachedContent existing = get(name);\n\t\tif (existing == null) {\n\t\t\tthrow new CachedContentException(\"Cached content not found: \" + name);\n\t\t}\n\n\t\tInstant newExpireTime = existing.getExpireTime() != null ? existing.getExpireTime().plus(additionalTtl)\n\t\t\t\t: Instant.now().plus(additionalTtl);\n\n\t\tCachedContentUpdateRequest updateRequest = CachedContentUpdateRequest.builder()\n\t\t\t.expireTime(newExpireTime)\n\t\t\t.build();\n\n\t\treturn update(name, updateRequest);\n\t}\n\n\t/**\n\t * Refreshes the expiration of cached content to the maximum TTL.\n\t * @param name the cached content name\n\t * @param maxTtl the maximum TTL to set\n\t * @return the updated cached content\n\t */","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/models/spring-ai-google-genai/src/main/java/org/springframework/ai/google/genai/cache/GoogleGenAiCachedContentService.java#L369-L405","documentation":"extendTtl(name, additionalTtl) first loads the cached content via get(name); if it returns null (name not found or already expired/removed) it throws CachedContentException directly with the name in the message. This is a pre-condition check, not a wrapped remote error.","triggerScenarios":"Calling extendTtl with a name that does not exist, was deleted, or whose TTL already lapsed so Google removed the resource.","commonSituations":"Background jobs refreshing TTL of cache entries that expired between runs, typos in fully-qualified resource names, or caches created in a different project/region.","solutions":["Call get(name) before extendTtl and recreate the cached content if null","Refresh TTLs at intervals shorter than the entry TTL","Verify the resource name and project/region","Catch CachedContentException and treat as recreation signal"],"exampleFix":"// before\nservice.extendTtl(name, Duration.ofHours(1));\n// after\nif (service.get(name) == null) {\n    service.create(buildCreateRequest(name)); // recreate instead\n} else {\n    service.extendTtl(name, Duration.ofHours(1));\n}","handlingStrategy":"validation","validationCode":"GoogleGenAiCachedContent existing = service.get(name);\nif (existing == null) {\n    // recreate or skip; do not call extendTtl\n} else {\n    service.extendTtl(name, additionalTtl);\n}","typeGuard":null,"tryCatchPattern":"try {\n    service.extendTtl(name, additionalTtl);\n} catch (CachedContentException e) {\n    logger.warn(\"cache entry {} gone; recreating\", name);\n    recreateCache(name);\n}","preventionTips":["Always check get(name) != null before extendTtl","Run TTL refresh jobs more often than the shortest TTL","Handle expired entries by recreating, not updating","Verify the resource name and project/region"],"tags":["google-genai","caching","ttl","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}