The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Show failed Metabot tool calls as failed in Slack (#85130)
Andrei Simionescu8ebb6ff18d8a
diff --git a/src/metabase/slackbot/streaming.clj b/src/metabase/slackbot/streaming.cljindex 7197d95516a..6bb136ac2a2 100644--- a/src/metabase/slackbot/streaming.clj+++ b/src/metabase/slackbot/streaming.clj@@ -625,7 +625,7 @@:id id:title (tool-friendly-names tool-name "Thinking"):status status}])- (when (= status "complete")+ (when (#{"complete" "error"} status)(swap! pending-text #(str "\n\n" %)))nil))))@@ -634,8 +634,8 @@(swap! tool-id->name assoc id tool-name)(send-task-update! id tool-name "in_progress"))- on-tool-end (fn [{:keys [id]}]- (send-task-update! id (get @tool-id->name id) "complete")+ on-tool-end (fn [{:keys [id result]}]+ (send-task-update! id (get @tool-id->name id) (if (:error result) "error" "complete"))(swap! tool-id->name dissoc id))prefetched-viz (atom {})diff --git a/test/metabase/slackbot/streaming_test.clj b/test/metabase/slackbot/streaming_test.cljindex d70158c8ae7..f155b178d74 100644--- a/test/metabase/slackbot/streaming_test.clj+++ b/test/metabase/slackbot/streaming_test.clj@@ -791,6 +791,26 @@[{:type :tool-input :id "call-1" :function "search" :arguments {:term_queries ["orders"]}}{:type :tool-output :id "call-1" :result {:output "No results."}}])+(deftest ^:synchronized slackbot-dm-tool-outcome-status-test+ (doseq [[outcome status] [[{:output "OK"} "complete"]+ [{:output "OK" :error nil} "complete"]+ [{:output "Invalid arguments: private detail"+ :error {:class :validation :code :invalid-arguments}} "error"]+ [{:output "Card 123 not found: private detail"+ :error {:class :recoverable :code :test/not-found}} "error"]+ [{:output "This call failed (:internal)"+ :error {:class :unrecoverable :code :internal+ :user-message "Private detail"}} "error"]]]+ (testing (pr-str outcome)+ (let [{:keys [appended task-updates]}+ (dm-turn-with-parts! [{:type :tool-input :id "call-1" :function "static_viz"+ :arguments {:entity_id 123}}+ {:type :tool-output :id "call-1" :result outcome}])]+ (is (= [{:type "task_update" :id "call-1" :title "Running query" :status "in_progress"}+ {:type "task_update" :id "call-1" :title "Running query" :status status}]+ task-updates))+ (is (= "\n\n" appended))))))+(deftest ^:synchronized slackbot-dm-textless-reply-with-tool-progress-has-no-fallback-test(testing "a reply that showed tool progress is not an empty reply -- no fallback copy"(let [{:keys [appended blocks task-updates deleted]} (dm-turn-with-parts! search-tool-parts)]