{"record":{"id":"263212bd3b3ff1f2","repo":"invoke-ai/InvokeAI","slug":"system-prompt-not-found","errorCode":null,"errorMessage":"System prompt not found","messagePattern":"System prompt not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"invokeai/app/api/routers/system_prompts.py","lineNumber":45,"sourceCode":"    if config.multiuser and not current_user.is_admin:\n        user_id_filter = current_user.user_id\n    return ApiDependencies.invoker.services.system_prompt_records.get_many(user_id=user_id_filter)\n\n\n@system_prompts_router.get(\n    \"/i/{system_prompt_id}\",\n    operation_id=\"get_system_prompt\",\n    responses={200: {\"model\": SystemPromptRecordDTO}},\n)\ndef get_system_prompt(\n    current_user: CurrentUserOrDefault,\n    system_prompt_id: str = Path(description=\"The id of the system prompt to get\"),\n) -> SystemPromptRecordDTO:\n    \"\"\"Gets a system prompt by id.\"\"\"\n    try:\n        prompt = ApiDependencies.invoker.services.system_prompt_records.get(system_prompt_id)\n    except SystemPromptNotFoundError:\n        raise HTTPException(status_code=404, detail=\"System prompt not found\")\n\n    config = ApiDependencies.invoker.services.configuration\n    if config.multiuser:\n        is_owner = prompt.user_id == current_user.user_id\n        if not (is_owner or prompt.is_public or current_user.is_admin):\n            raise HTTPException(status_code=403, detail=\"Not authorized to access this system prompt\")\n    return prompt\n\n\n@system_prompts_router.post(\n    \"/\",\n    operation_id=\"create_system_prompt\",\n    responses={200: {\"model\": SystemPromptRecordDTO}},\n)\ndef create_system_prompt(\n    current_user: CurrentUserOrDefault,\n    system_prompt: SystemPromptWithoutId = Body(description=\"The system prompt to create\"),\n) -> SystemPromptRecordDTO:","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/system_prompts.py#L27-L63","documentation":"get_system_prompt (GET /system_prompts/i/{id}) calls system_prompt_records.get; if no record exists for the id, the service raises SystemPromptNotFoundError, mapped to HTTP 404 'System prompt not found'. This is a plain not-found error for an unknown or deleted system prompt id.","triggerScenarios":"GET /system_prompts/i/{system_prompt_id} with an id that was never created, was deleted, comes from another InvokeAI instance/dataset, or contains a typo/wrong id format.","commonSituations":"Cached or bookmarked ids after reinstalling/wiping the database; copying ids from a different environment (dev vs prod); stale client state after another user deleted the prompt; id vs name confusion in scripts.","solutions":["GET /system_prompts/ (list) and confirm the exact id exists — use that id verbatim.","Handle 404 in the client by refreshing the list rather than retrying the same id.","Check you are pointing at the intended instance/database (the prompt may live on another install).","If the id came from another service, verify it is a system prompt id and not a style preset or other entity id."],"exampleFix":"// before\nconst prompt = await client.getSystemPrompt(idFromCache); // may 404\n\n// after\nconst prompts = await client.listSystemPrompts();\nconst prompt = prompts.find((p) => p.id === idFromCache);\nif (!prompt) return fallbackPrompt; // handle deleted ids gracefully","handlingStrategy":"try-catch","validationCode":"const uuidLike = /^[0-9a-fA-F-]{10,}$/;\nfunction plausiblyValidPromptId(id) {\n  return typeof id === \"string\" && id.length > 0 && uuidLike.test(id);\n}\n\nif (!plausiblyValidPromptId(id)) throw new Error(\"malformed system prompt id — refresh from list endpoint\");","typeGuard":"function isNonEmptyId(id: unknown): id is string {\n  return typeof id === \"string\" && id.trim().length > 0;\n}","tryCatchPattern":"try {\n  const prompt = await api.getSystemPrompt(id);\n} catch (e) {\n  if (e.status === 404 && e.detail === \"System prompt not found\") {\n    const prompts = await api.listSystemPrompts(); // refresh ids; use fallback or null\n  } else throw e;\n}","preventionTips":["Always resolve ids from GET /system_prompts/ instead of hardcoding or caching them.","Treat 404 as 'refresh your cached list', not retryable.","Don't reuse ids across environments/instances (dev vs prod databases differ).","Distinguish system prompt ids from style preset or other entity ids in scripts."],"tags":["http-404","not-found","rest-api","fastapi"],"backgroundTag":"resource-not-found","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}