odysseus-dev/odysseus · warning · HTTPException

Event name is required for event-triggered tasks

Error message

Event name is required for event-triggered tasks

What it means

Create-task validation: trigger_type 'event' requires trigger_event naming the event that fires the task. Without an event name the scheduler cannot subscribe the task, so the request fails with HTTP 400.

Source

Thrown at routes/task_routes.py:475

            raise HTTPException(400, "Prompt is required for LLM/research tasks")
        if req.task_type == "action" and not req.action:
            raise HTTPException(400, "Action name is required for action tasks")
        # Block shell-executing action types for non-admins. action_run_local
        # uses subprocess.run(shell=True) and ssh_command / run_script run
        # arbitrary commands.
        _require_admin_for_task_action(user, req.task_type, req.action)
        if req.trigger_type == "schedule" and not req.schedule:
            raise HTTPException(400, "Schedule is required for schedule-triggered tasks")
        if req.trigger_type == "schedule" and req.schedule == "cron" and not req.cron_expression:
            raise HTTPException(400, "Cron expression is required for cron schedule")
        if req.trigger_type == "schedule" and req.schedule == "cron" and req.cron_expression:
            try:
                from croniter import croniter
                croniter(req.cron_expression)
            except Exception:
                raise HTTPException(400, "Invalid cron expression")
        if req.trigger_type == "event" and not req.trigger_event:
            raise HTTPException(400, "Event name is required for event-triggered tasks")
        if req.trigger_type == "event" and not req.trigger_count:
            raise HTTPException(400, "Trigger count is required for event-triggered tasks")

        # Auto-generate name
        name = req.name
        if not name:
            if req.task_type == "action":
                from src.builtin_actions import BUILTIN_ACTION_INFO
                name = BUILTIN_ACTION_INFO.get(req.action, req.action or "Action Task")
            elif req.prompt:
                name = await _generate_task_name(req.prompt, owner=user)
            else:
                name = "Untitled Task"

        # Compute next_run for schedule-triggered tasks
        next_run = None
        sched_date = None
        if req.trigger_type == "schedule":

View on GitHub (pinned to f9235ebbf1)

Solutions

  1. Set trigger_event to a known event name in the request body.
  2. Populate the client's event picker from the API's event list and require a selection before submit.
  3. Verify the exact event name spelling/casing the backend emits (events are matched by string).

Example fix

// before
{task_type: 'llm', prompt, trigger_type: 'event'}

// after
{task_type: 'llm', prompt, trigger_type: 'event', trigger_event: 'email.received', trigger_count: 1}
Defensive patterns

Strategy: validation

Validate before calling

function validateEventTask(p) {
  if (p.trigger_type === 'event' && !(p.trigger_event ?? '').trim())
    throw new ValidationError('Event name is required');
  return p;
}

Type guard

function isEventTask(p: unknown): p is {trigger_type: 'event'; trigger_event: string} {
  return typeof p === 'object' && p !== null &&
    (p as any).trigger_type === 'event' &&
    typeof (p as any).trigger_event === 'string' && (p as any).trigger_event.length > 0;
}

Prevention

When it happens

Trigger: POST /api/tasks with {"trigger_type": "event"} and trigger_event null/empty (trigger_count may also need setting — it is checked next).

Common situations: Event dropdown not populated yet when submitted; webhook vs event trigger types confused in the client; event renamed server-side so the old value is cleared by validation; JSON import missing the field.

Related errors


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