From fd6fc6b931ddbe4dc0536c0d1619ff0fbf868b53 Mon Sep 17 00:00:00 2001 From: Grendgi Date: Fri, 5 Jun 2026 16:31:20 +0300 Subject: [PATCH] Handle scalar TG extracted payloads --- cmd/classifier/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/classifier/main.go b/cmd/classifier/main.go index 106288e..d531bfc 100644 --- a/cmd/classifier/main.go +++ b/cmd/classifier/main.go @@ -300,7 +300,12 @@ func (c *classifier) resolvePrompt(ctx context.Context, vertical, departmentID, func (c *classifier) saveVerdict(ctx context.Context, id int64, key string, verdict json.RawMessage) error { _, err := c.db.Exec(ctx, ` UPDATE messages - SET extracted = jsonb_set(COALESCE(extracted, '{}'::jsonb), ARRAY[$2], $3::jsonb, true) + SET extracted = jsonb_set( + CASE WHEN jsonb_typeof(extracted) = 'object' THEN extracted ELSE '{}'::jsonb END, + ARRAY[$2], + $3::jsonb, + true + ) WHERE id = $1 `, id, key, string(verdict)) return err