odysseus-dev/odysseus · warning · HTTPException

This task has no clearable cache

Error message

This task has no clearable cache

What it means

POST /api/tasks/{task_id}/clear-cache maps the task's action to clearable cache tables via a whitelist (summarize_emails, draft_email_replies, email_auto_translate, extract_email_events, learn_sender_signatures, check_email_urgency). If the task's action is not in that dict (including non-action tasks whose action field is empty), there is nothing derived to purge and the route returns HTTP 400.

Source

Thrown at routes/task_routes.py:597

            if not task:
                raise HTTPException(404, "Task not found")
            if user and task.owner != user:
                raise HTTPException(403, "Access denied")
            action = task.action or ""
        finally:
            db.close()

        cache_tables = {
            "summarize_emails": ("email_summaries",),
            "draft_email_replies": ("email_ai_replies",),
            "email_auto_translate": ("email_translations",),
            "extract_email_events": ("email_calendar_extractions",),
            "learn_sender_signatures": ("sender_signatures",),
            "check_email_urgency": ("email_tags", "email_urgency_alerts"),
        }
        tables = cache_tables.get(action)
        if not tables:
            raise HTTPException(400, "This task has no clearable cache")

        import sqlite3
        from pathlib import Path
        from routes.email_helpers import SCHEDULED_DB, OWNER_SCOPED_EMAIL_CACHE_TABLES, _email_cache_owner_clause

        cleared = {}
        conn = sqlite3.connect(SCHEDULED_DB)
        try:
            for table in tables:
                try:
                    if table == "email_tags" and user:
                        before = conn.execute(
                            "SELECT COUNT(*) FROM email_tags WHERE owner = ? OR owner = ''",
                            (user,),
                        ).fetchone()[0]
                        conn.execute("DELETE FROM email_tags WHERE owner = ? OR owner = ''", (user,))
                    elif table in OWNER_SCOPED_EMAIL_CACHE_TABLES and user:
                        owner_clause, owner_params = _email_cache_owner_clause(user)

View on GitHub (pinned to f9235ebbf1)

Solutions

  1. Only offer/attempt clear-cache for tasks whose action is one of the whitelisted email actions.
  2. Check task.action client-side against the whitelist before calling the endpoint.
  3. When adding a new derived-cache action server-side, register its tables in the cache_tables dict so the endpoint supports it.

Example fix

// before
rows.forEach(t => t.showClearCache = true);

// after
const CLEARABLE = new Set(['summarize_emails','draft_email_replies','email_auto_translate','extract_email_events','learn_sender_signatures','check_email_urgency']);
rows.forEach(t => t.showClearCache = CLEARABLE.has(t.action));
Defensive patterns

Strategy: type-guard

Validate before calling

const CLEARABLE_ACTIONS = new Set(['summarize_emails','draft_email_replies','email_auto_translate','extract_email_events','learn_sender_signatures','check_email_urgency']);
const canClear = (task) => CLEARABLE_ACTIONS.has(task.action ?? '');

Type guard

function hasClearableCache(task: {action?: string | null}): boolean {
  const CLEARABLE = new Set(['summarize_emails','draft_email_replies','email_auto_translate','extract_email_events','learn_sender_signatures','check_email_urgency']);
  return typeof task.action === 'string' && CLEARABLE.has(task.action);
}

Prevention

When it happens

Trigger: Calling clear-cache on an llm/research task (action empty), an action task with an action name outside the whitelist (e.g. action_run_local), or a custom/new action whose cache table was never registered in cache_tables.

Common situations: UI shows a 'Clear cache' button on every task row instead of only cached email actions; new built-in action added without extending cache_tables; user assumes all tasks have server-side caches.

Related errors


AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14). Data as JSON: /api/errors/0536af796cc5e096. Report an issue: GitHub.