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
fix: error message for unauthenticated requests is generic (#69352)
Maksym Yakubych1be2cb84972c
diff --git a/enterprise/frontend/src/metabase-enterprise/metabot/constants.ts b/enterprise/frontend/src/metabase-enterprise/metabot/constants.tsindex 4356a186f61..6d01b79202a 100644--- a/enterprise/frontend/src/metabase-enterprise/metabot/constants.ts+++ b/enterprise/frontend/src/metabase-enterprise/metabot/constants.ts@@ -27,6 +27,9 @@ export const METABOT_ERR_MSG = {get default() {return t`Sorry, I ran into an error. Could you please try that again?`;},+ get unauthenticated() {+ return t`Metabot could not authenticate your request. Please contact your administrator.`;+ },get agentOffline() {return t`Metabot is currently offline. Please try again later.`;},diff --git a/enterprise/frontend/src/metabase-enterprise/metabot/state/actions.ts b/enterprise/frontend/src/metabase-enterprise/metabot/state/actions.tsindex d6edc5f276d..2c38fa37bb9 100644--- a/enterprise/frontend/src/metabase-enterprise/metabot/state/actions.ts+++ b/enterprise/frontend/src/metabase-enterprise/metabot/state/actions.ts@@ -92,6 +92,17 @@ const handleResponseError = (error: unknown): PromptErrorOutcome => {errorMessage: false as const,shouldRetry: false,}))+ .with(+ { message: P.string.startsWith("Response status: 401") },+ { status: 401 },+ () => ({+ errorMessage: {+ type: "alert" as const,+ message: METABOT_ERR_MSG.unauthenticated,+ },+ shouldRetry: true,+ }),+ ).with({ message: P.string.startsWith("Response status: 5") },{ status: 500 },diff --git a/enterprise/frontend/src/metabase-enterprise/metabot/tests/errors.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/metabot/tests/errors.unit.spec.tsxindex b07ce555957..5dd70de9ef0 100644--- a/enterprise/frontend/src/metabase-enterprise/metabot/tests/errors.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/metabot/tests/errors.unit.spec.tsx@@ -41,6 +41,19 @@ describe("metabot > errors", () => {expect(await input()).toHaveTextContent("Who is your favorite?");});+ it("should show a better error message for unauthenticated requests", async () => {+ setup();+ fetchMock.post(`path:/api/ee/metabot-v3/agent-streaming`, 401);++ await enterChatMessage("Who is your favorite?");++ await assertConversation([+ ["user", "Who is your favorite?"],+ ["agent", METABOT_ERR_MSG.unauthenticated],+ ]);+ expect(await input()).toHaveTextContent("Who is your favorite?");+ });+it("should handle show error if data error part is in response", async () => {setup();mockAgentEndpoint({ textChunks: erroredResponse });