Fix 422 on agent trigger: accept plural data type names

AgentTriggerRequest.what_to_extract now accepts list[str] instead of
strict Literal values. _to_data_types normalises all FE variants
(tasks/task, notes/note, timelines/timeline/timelineEvents,
projects/project) to the canonical plural form the runner expects,
with deduplication.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Roberto Musso
2026-03-18 00:04:29 +01:00
parent 5a03bd1cfb
commit 297e20ce8d
2 changed files with 14 additions and 10 deletions

View File

@@ -49,12 +49,19 @@ def _dt_ms_opt(dt: datetime | None) -> int | None:
def _to_data_types(values: list[str]) -> list[str]:
normalize = {
"task": "tasks",
"note": "notes",
"timeline": "timelines",
"project": "projects",
"task": "tasks", "tasks": "tasks",
"note": "notes", "notes": "notes",
"timeline": "timelines", "timelines": "timelines", "timelineEvents": "timelines",
"project": "projects", "projects": "projects",
}
return [normalize[v] for v in values if v in normalize]
seen: set[str] = set()
result: list[str] = []
for v in values:
mapped = normalize.get(v)
if mapped and mapped not in seen:
seen.add(mapped)
result.append(mapped)
return result
def _to_run_log_response(log: AgentRunLog) -> AgentRunLogResponse: