From 9e7497412924f102b2e2509745c1feb906cb370d Mon Sep 17 00:00:00 2001 From: Luan Vu Date: Fri, 27 Mar 2026 13:42:31 +0700 Subject: [PATCH] fix: feishu reply context truncation + task events NULL data crash (#508) * fix(feishu): increase reply context max length from 500 to 2000 500 bytes is too short for CJK/Unicode text (each accented char = 2-3 bytes, so ~250 real characters). Increase to 2000 so reply context is not aggressively truncated. * fix(teams): handle NULL data column in task events queries ListTaskEvents and ListTeamEvents crash with "unsupported Scan, storing driver.Value type into type *json.RawMessage" when the data column is NULL. Use COALESCE(data, '{}') to return an empty JSON object instead. --------- Co-authored-by: Luvu182 <208665161+Luvu182@users.noreply.github.com> --- internal/channels/feishu/bot.go | 2 +- internal/store/pg/teams_tasks_activity.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/channels/feishu/bot.go b/internal/channels/feishu/bot.go index 38206db2..62809d00 100644 --- a/internal/channels/feishu/bot.go +++ b/internal/channels/feishu/bot.go @@ -277,7 +277,7 @@ func (c *Channel) handleMessageEvent(ctx context.Context, event *MessageEvent) { } } -const replyContextMaxLen = 500 +const replyContextMaxLen = 2000 // fetchReplyContext fetches the parent message content and returns a formatted // reply context string + any downloaded media from the parent message. diff --git a/internal/store/pg/teams_tasks_activity.go b/internal/store/pg/teams_tasks_activity.go index d8d8de6b..69bfe801 100644 --- a/internal/store/pg/teams_tasks_activity.go +++ b/internal/store/pg/teams_tasks_activity.go @@ -132,7 +132,7 @@ func (s *PGTeamStore) RecordTaskEvent(ctx context.Context, event *store.TeamTask func (s *PGTeamStore) ListTaskEvents(ctx context.Context, taskID uuid.UUID) ([]store.TeamTaskEventData, error) { tid := tenantIDForInsert(ctx) rows, err := s.db.QueryContext(ctx, - `SELECT id, task_id, event_type, actor_type, actor_id, data, created_at + `SELECT id, task_id, event_type, actor_type, actor_id, COALESCE(data, '{}'), created_at FROM team_task_events WHERE task_id = $1 AND tenant_id = $2 ORDER BY created_at ASC`, taskID, tid) @@ -160,7 +160,7 @@ func (s *PGTeamStore) ListTeamEvents(ctx context.Context, teamID uuid.UUID, limi } tid := tenantIDForInsert(ctx) rows, err := s.db.QueryContext(ctx, - `SELECT e.id, e.task_id, e.event_type, e.actor_type, e.actor_id, e.data, e.created_at + `SELECT e.id, e.task_id, e.event_type, e.actor_type, e.actor_id, COALESCE(e.data, '{}'), e.created_at FROM team_task_events e JOIN team_tasks t ON t.id = e.task_id WHERE t.team_id = $1 AND t.tenant_id = $4