:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(slack_app): accept a backticked project id in the project command (#87335)
posthog[bot]9e595d2cddc9
diff --git a/products/slack_app/backend/api.py b/products/slack_app/backend/api.pyindex 66859ebcb5bb..746cd8531d36 100644--- a/products/slack_app/backend/api.py+++ b/products/slack_app/backend/api.py@@ -805,14 +805,18 @@ def parse_rules_command(text: str) -> RulesCommand | None:# `project workspace <id>` sets the workspace-wide default and must be tested# before the generic `project` branch. Trailing text after the id is ignored.+ # `[`*_]*` lets the id keep the Slack code or emphasis formatting the picker+ # message wraps it in, so a pasted `452770` still parses.project_workspace_match = re.fullmatch(- r"project\s+workspace\s+(\d+)(?:\s+.*)?", cleaned, flags=re.IGNORECASE | re.DOTALL+ r"project\s+workspace\s+[`*_]*(\d+)[`*_]*(?:\s+.*)?", cleaned, flags=re.IGNORECASE | re.DOTALL)if project_workspace_match is not None:return RulesCommand(action="project_set_workspace", project_team_id=int(project_workspace_match.group(1)))# Trailing text after the id is tolerated but ignored — we only act on the id.- project_match = re.fullmatch(r"project(?:\s+(\d+)(?:\s+.*)?)?", cleaned, flags=re.IGNORECASE | re.DOTALL)+ project_match = re.fullmatch(+ r"project(?:\s+[`*_]*(\d+)[`*_]*(?:\s+.*)?)?", cleaned, flags=re.IGNORECASE | re.DOTALL+ )if project_match is not None:team_id_str = project_match.group(1)if team_id_str is None:diff --git a/products/slack_app/backend/tests/test_project_directive_parser.py b/products/slack_app/backend/tests/test_project_directive_parser.pyindex b531bbdf1709..277077de3d6b 100644--- a/products/slack_app/backend/tests/test_project_directive_parser.py+++ b/products/slack_app/backend/tests/test_project_directive_parser.py@@ -46,6 +46,21 @@ class TestParseProjectCommand:"project 12 build feature",RulesCommand(action="project_set", project_team_id=12),),+ (+ "set_backticked_id",+ "project `452770`",+ RulesCommand(action="project_set", project_team_id=452770),+ ),+ (+ "set_bold_id",+ "project *452770*",+ RulesCommand(action="project_set", project_team_id=452770),+ ),+ (+ "set_italic_id_with_request",+ "project _19_ fix auth",+ RulesCommand(action="project_set", project_team_id=19),+ ),("show_plain", "project", RulesCommand(action="project_show")),("show_uppercase", "PROJECT", RulesCommand(action="project_show")),("show_trailing_whitespace", "project ", RulesCommand(action="project_show")),@@ -75,6 +90,16 @@ class TestParseProjectCommand:"project workspace 6",RulesCommand(action="project_set_workspace", project_team_id=6),),+ (+ "workspace_set_backticked_id",+ "project workspace `452770`",+ RulesCommand(action="project_set_workspace", project_team_id=452770),+ ),+ (+ "workspace_set_bold_id",+ "project workspace *8*",+ RulesCommand(action="project_set_workspace", project_team_id=8),+ ),])def test_recognized(self, _name: str, text: str, expected: RulesCommand) -> None: