diff --git a/CHANGELOG.md b/CHANGELOG.md index 32866731..3eab1d6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,8 +21,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - fixed incorrect message id field used ([#378](https://github.com/opensearch-project/dashboards-assistant/pull/378)) - Improve alert summary with backend log pattern experience ([#389](https://github.com/opensearch-project/dashboards-assistant/pull/389)) -- fixed in context feature returning 500 error if workspace is invalid to returning 4XX [#429](https://github.com/opensearch-project/dashboards-assistant/pull/429) - +- fixed in context feature returning 500 error if workspace is invalid to returning 4XX ([#429](https://github.com/opensearch-project/dashboards-assistant/pull/429))([#458](https://github.com/opensearch-project/dashboards-assistant/pull/458)) ### Infrastructure diff --git a/server/routes/summary_routes.ts b/server/routes/summary_routes.ts index df73d51c..f58ae31a 100644 --- a/server/routes/summary_routes.ts +++ b/server/routes/summary_routes.ts @@ -51,25 +51,25 @@ export function registerSummaryAssistantRoutes( }, }, router.handleLegacyErrors(async (context, req, res) => { - const client = await getOpenSearchClientTransport({ - context, - dataSourceId: req.query.dataSourceId, - }); - const assistantClient = assistantService.getScopedClient(req, context); - let isLogIndex = false; - if (req.body.index) { - isLogIndex = await detectIndexType( - client, - assistantClient, - req.body.index, - req.query.dataSourceId - ); - } - const agentConfigId = - req.body.index && req.body.dsl && isLogIndex - ? LOG_PATTERN_SUMMARY_AGENT_CONFIG_ID - : SUMMARY_AGENT_CONFIG_ID; try { + const client = await getOpenSearchClientTransport({ + context, + dataSourceId: req.query.dataSourceId, + }); + const assistantClient = assistantService.getScopedClient(req, context); + let isLogIndex = false; + if (req.body.index) { + isLogIndex = await detectIndexType( + client, + assistantClient, + req.body.index, + req.query.dataSourceId + ); + } + const agentConfigId = + req.body.index && req.body.dsl && isLogIndex + ? LOG_PATTERN_SUMMARY_AGENT_CONFIG_ID + : SUMMARY_AGENT_CONFIG_ID; const response = await assistantClient.executeAgentByConfigName(agentConfigId, { context: req.body.context, question: req.body.question,