Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix unhandled exception when workspace id not exists #458

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 18 additions & 18 deletions server/routes/summary_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading