fix(kanban): guard task_age against corrupt created_at values like '%s'

task_age() crashed with ValueError when created_at contained the
literal format string '%s' instead of a Unix timestamp, taking down
the entire GET /board endpoint with a 500.

- Add _safe_int() helper that returns None on non-numeric values
- Refactor task_age() to use _safe_int instead of bare int() casts
- Wrap task_age() call in _task_dict with try/except fallback so one
  corrupt row never kills the whole board endpoint
This commit is contained in:
baocin 2026-05-06 18:18:56 -05:00 committed by Teknium
parent c39168453d
commit 061a183008
2 changed files with 20 additions and 7 deletions

View file

@ -145,7 +145,10 @@ def _task_dict(
d = asdict(task)
# Add derived age metrics so the UI can colour stale cards without
# computing deltas client-side.
d["age"] = kanban_db.task_age(task)
try:
d["age"] = kanban_db.task_age(task)
except Exception:
d["age"] = {"created_age_seconds": None, "started_age_seconds": None, "time_to_complete_seconds": None}
# Surface the latest non-null run summary so dashboards don't show
# blank cards/drawers for tasks where the worker handed off via
# ``task_runs.summary`` (the kanban-worker pattern) instead of