invoke-ai/InvokeAI · error · HTTPException
System prompt not found
Error message
System prompt not found
What it means
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.
Source
Thrown at invokeai/app/api/routers/system_prompts.py:45
if config.multiuser and not current_user.is_admin:
user_id_filter = current_user.user_id
return ApiDependencies.invoker.services.system_prompt_records.get_many(user_id=user_id_filter)
@system_prompts_router.get(
"/i/{system_prompt_id}",
operation_id="get_system_prompt",
responses={200: {"model": SystemPromptRecordDTO}},
)
def get_system_prompt(
current_user: CurrentUserOrDefault,
system_prompt_id: str = Path(description="The id of the system prompt to get"),
) -> SystemPromptRecordDTO:
"""Gets a system prompt by id."""
try:
prompt = ApiDependencies.invoker.services.system_prompt_records.get(system_prompt_id)
except SystemPromptNotFoundError:
raise HTTPException(status_code=404, detail="System prompt not found")
config = ApiDependencies.invoker.services.configuration
if config.multiuser:
is_owner = prompt.user_id == current_user.user_id
if not (is_owner or prompt.is_public or current_user.is_admin):
raise HTTPException(status_code=403, detail="Not authorized to access this system prompt")
return prompt
@system_prompts_router.post(
"/",
operation_id="create_system_prompt",
responses={200: {"model": SystemPromptRecordDTO}},
)
def create_system_prompt(
current_user: CurrentUserOrDefault,
system_prompt: SystemPromptWithoutId = Body(description="The system prompt to create"),
) -> SystemPromptRecordDTO:View on GitHub (pinned to 0b6a024f2f)
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.
Example fix
// before const prompt = await client.getSystemPrompt(idFromCache); // may 404 // after const prompts = await client.listSystemPrompts(); const prompt = prompts.find((p) => p.id === idFromCache); if (!prompt) return fallbackPrompt; // handle deleted ids gracefully
Defensive patterns
Strategy: try-catch
Validate before calling
const uuidLike = /^[0-9a-fA-F-]{10,}$/;
function plausiblyValidPromptId(id) {
return typeof id === "string" && id.length > 0 && uuidLike.test(id);
}
if (!plausiblyValidPromptId(id)) throw new Error("malformed system prompt id — refresh from list endpoint"); Type guard
function isNonEmptyId(id: unknown): id is string {
return typeof id === "string" && id.trim().length > 0;
} Try / catch
try {
const prompt = await api.getSystemPrompt(id);
} catch (e) {
if (e.status === 404 && e.detail === "System prompt not found") {
const prompts = await api.listSystemPrompts(); // refresh ids; use fallback or null
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Board not found
- Video record not found
- Image not found
- Board not found
- str(e) (ValueError, relationship not found)
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/263212bd3b3ff1f2.
Report an issue: GitHub.