Skip to content

Commit 23896ad

Browse files
authored
fix unhandled exception when workspace id not exists (#458)
* fix unhandled exception when workspace id not exists Signed-off-by: Yulong Ruan <[email protected]> * update CHANGELOG Signed-off-by: Yulong Ruan <[email protected]> --------- Signed-off-by: Yulong Ruan <[email protected]>
1 parent d61eecb commit 23896ad

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
2121

2222
- fixed incorrect message id field used ([#378](https://github.com/opensearch-project/dashboards-assistant/pull/378))
2323
- Improve alert summary with backend log pattern experience ([#389](https://github.com/opensearch-project/dashboards-assistant/pull/389))
24-
- fixed in context feature returning 500 error if workspace is invalid to returning 4XX [#429](https://github.com/opensearch-project/dashboards-assistant/pull/429)
25-
24+
- 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))
2625

2726
### Infrastructure
2827

server/routes/summary_routes.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,25 @@ export function registerSummaryAssistantRoutes(
5151
},
5252
},
5353
router.handleLegacyErrors(async (context, req, res) => {
54-
const client = await getOpenSearchClientTransport({
55-
context,
56-
dataSourceId: req.query.dataSourceId,
57-
});
58-
const assistantClient = assistantService.getScopedClient(req, context);
59-
let isLogIndex = false;
60-
if (req.body.index) {
61-
isLogIndex = await detectIndexType(
62-
client,
63-
assistantClient,
64-
req.body.index,
65-
req.query.dataSourceId
66-
);
67-
}
68-
const agentConfigId =
69-
req.body.index && req.body.dsl && isLogIndex
70-
? LOG_PATTERN_SUMMARY_AGENT_CONFIG_ID
71-
: SUMMARY_AGENT_CONFIG_ID;
7254
try {
55+
const client = await getOpenSearchClientTransport({
56+
context,
57+
dataSourceId: req.query.dataSourceId,
58+
});
59+
const assistantClient = assistantService.getScopedClient(req, context);
60+
let isLogIndex = false;
61+
if (req.body.index) {
62+
isLogIndex = await detectIndexType(
63+
client,
64+
assistantClient,
65+
req.body.index,
66+
req.query.dataSourceId
67+
);
68+
}
69+
const agentConfigId =
70+
req.body.index && req.body.dsl && isLogIndex
71+
? LOG_PATTERN_SUMMARY_AGENT_CONFIG_ID
72+
: SUMMARY_AGENT_CONFIG_ID;
7373
const response = await assistantClient.executeAgentByConfigName(agentConfigId, {
7474
context: req.body.context,
7575
question: req.body.question,

0 commit comments

Comments
 (0)