From bbd900635ea4c5c27fe5362295f509a385cf1097 Mon Sep 17 00:00:00 2001 From: Bohan Jiang <52446949+Bohan-J@users.noreply.github.com> Date: Wed, 1 Jul 2026 15:20:22 +0800 Subject: [PATCH] fix(slack): allow slack_chat issue origin so /issue can create issues (MUL-3908) (#4785) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to #4780 (the /issue slash command), which merged the code + docs. The DB migration was pushed to that branch after it had already been squash-merged, so it never landed on main — the /issue command still fails at issue creation. The issue.origin_type CHECK constraint (migration 111) only allowed autopilot / quick_create / lark_chat. Slack stamps origin_type='slack_chat' on every /issue create, so the INSERT trips SQLSTATE 23514 and IssueService.Create fails ("Something went wrong creating the issue"). This also silently broke the pre-existing message-based Slack /issue. Extends the constraint to include 'slack_chat', mirroring 111 (lark_chat). Numbered 131 because 129/130 were taken on main since #4780 branched. Verified against a real Postgres: full chain up to 131 applies cleanly and an issue insert with origin_type='slack_chat' passes the CHECK after 131 (fails with the pre-131 constraint). Co-authored-by: J Co-authored-by: multica-agent --- server/migrations/131_issue_origin_slack_chat.down.sql | 8 ++++++++ server/migrations/131_issue_origin_slack_chat.up.sql | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 server/migrations/131_issue_origin_slack_chat.down.sql create mode 100644 server/migrations/131_issue_origin_slack_chat.up.sql diff --git a/server/migrations/131_issue_origin_slack_chat.down.sql b/server/migrations/131_issue_origin_slack_chat.down.sql new file mode 100644 index 000000000..52a45cbe3 --- /dev/null +++ b/server/migrations/131_issue_origin_slack_chat.down.sql @@ -0,0 +1,8 @@ +-- Revert to the pre-slack_chat issue_origin_type_check list. Any existing rows +-- with origin_type='slack_chat' would violate the rolled-back constraint; the +-- down migration assumes the operator has already deleted or relabeled those +-- rows. Kept strict (no DROP NOT VALID dance) to preserve the schema invariant +-- downstream code relies on. Mirrors 111. +ALTER TABLE issue DROP CONSTRAINT IF EXISTS issue_origin_type_check; +ALTER TABLE issue ADD CONSTRAINT issue_origin_type_check + CHECK (origin_type IN ('autopilot', 'quick_create', 'lark_chat')); diff --git a/server/migrations/131_issue_origin_slack_chat.up.sql b/server/migrations/131_issue_origin_slack_chat.up.sql new file mode 100644 index 000000000..bc22c5791 --- /dev/null +++ b/server/migrations/131_issue_origin_slack_chat.up.sql @@ -0,0 +1,10 @@ +-- Extend issue.origin_type to allow the Slack `/issue` command paths (both the +-- message-prefix form and the slash command) to stamp issues with +-- origin_type='slack_chat'. The Slack integration shipped this origin label +-- (originSlackChat) but no migration ever added it to the CHECK list, so every +-- Slack /issue create tripped SQLSTATE 23514 and IssueService.Create failed — +-- surfaced end-to-end by the /issue slash command (MUL-3908). Mirrors 111 +-- (lark_chat), which fixed the identical gap for Lark. +ALTER TABLE issue DROP CONSTRAINT IF EXISTS issue_origin_type_check; +ALTER TABLE issue ADD CONSTRAINT issue_origin_type_check + CHECK (origin_type IN ('autopilot', 'quick_create', 'lark_chat', 'slack_chat'));