fix(dispatch): return 503 when OpenClaw gateway env missing

This commit is contained in:
Abhimanyu Saharan
2026-02-02 20:47:06 +05:30
parent 6b4773130c
commit 0caaaa1cb4

View File

@@ -9,6 +9,7 @@ from sqlmodel import Session, select
from app.api.utils import get_actor_employee_id, log_activity
from app.db.session import get_session
from app.integrations.notify import NotifyContext, notify_openclaw
from app.integrations.openclaw import OpenClawClient
from app.models.org import Employee
from app.models.work import Task, TaskComment
from app.schemas.work import TaskCommentCreate, TaskCreate, TaskUpdate
@@ -118,6 +119,12 @@ def dispatch_task(
_validate_task_assignee(session, task.assignee_employee_id)
if OpenClawClient.from_env() is None:
raise HTTPException(
status_code=503,
detail="OpenClaw gateway is not configured (set OPENCLAW_GATEWAY_URL/TOKEN)",
)
# Best-effort: enqueue an agent dispatch. This does not mutate the task.
background.add_task(
notify_openclaw,