invoke-ai/InvokeAI · error · HTTPException
Error getting client state keys
Error message
Error getting client state keys
What it means
HTTP 500 raised by get_client_state_keys_by_prefix when the persistence service throws while listing keys matching a prefix for the current user. Like the other client_state endpoints, the underlying error is only logged server-side.
Source
Thrown at invokeai/app/api/routers/client_state.py:65
@client_state_router.get(
"/{queue_id}/get_keys_by_prefix",
operation_id="get_client_state_keys_by_prefix",
response_model=list[str],
)
def get_client_state_keys_by_prefix(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id (ignored, kept for backwards compatibility)"),
prefix: str = Query(..., description="Prefix to filter keys by"),
) -> list[str]:
"""Gets client state keys matching a prefix for the current user"""
try:
return ApiDependencies.invoker.services.client_state_persistence.get_keys_by_prefix(
current_user.user_id, prefix
)
except Exception as e:
logging.error(f"Error getting client state keys: {e}")
raise HTTPException(status_code=500, detail="Error getting client state keys")
@client_state_router.post(
"/{queue_id}/delete_by_key",
operation_id="delete_client_state_by_key",
responses={204: {"description": "Client state key deleted"}},
)
def delete_client_state_by_key(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id (ignored, kept for backwards compatibility)"),
key: str = Query(..., description="Key to delete"),
) -> None:
"""Deletes a specific client state key for the current user"""
try:
ApiDependencies.invoker.services.client_state_persistence.delete_by_key(current_user.user_id, key)
except Exception as e:
logging.error(f"Error deleting client state key: {e}")
raise HTTPException(status_code=500, detail="Error deleting client state key")View on GitHub (pinned to 0b6a024f2f)
Solutions
- Check server logs for 'Error getting client state keys' with the root cause
- Confirm the client-state storage backend is healthy and migrated
- Retry with a narrower prefix to reduce scan size
- Restore/verify DB consistency if the backend reports corruption
Example fix
null
Defensive patterns
Strategy: fallback
Validate before calling
const healthy = await fetch('/health').then(r => r.ok).catch(() => false);
if (!healthy) throw new Error('Backend unavailable; skipping key prefix scan'); Type guard
const isClientStateKeysError = (e) => e?.response?.status === 500 && e?.response?.data?.detail === 'Error getting client state keys';
Try / catch
try {
keys = await api.get(`/client_state/${queueId}/get_keys_by_prefix`, { params: { prefix } });
} catch (e) {
if (isClientStateKeysError(e)) keys = []; // empty-list fallback
else throw e;
} Prevention
- Use narrow prefixes to limit backend scan size
- Keep the client-state backend migrated and reachable
- Cache known keys client-side to degrade gracefully during outages
When it happens
Trigger: GET /client_state/{queue_id}/get_keys_by_prefix where the backend key-scan/query fails (connection error, missing table, corrupted index).
Common situations: Database unavailable during startup or crash recovery; backend switched between implementations (e.g. SQLite to Postgres) with incomplete migration; very large key sets timing out the scan.
Related errors
- Error getting client state
- Error setting client state
- Error deleting client state key
- Error setting recall parameter {param_key}
- Failed to remove image from board
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/f1b30b48134087d4.
Report an issue: GitHub.