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

[Backport 2.x] 500 error if workspace is invalid #441

Merged
merged 1 commit into from
Feb 14, 2025
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
"micromatch": "^4.0.8",
"cross-spawn": "^7.0.5"
}
}
}
6 changes: 5 additions & 1 deletion server/routes/error_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ export const handleError = (e: any, res: OpenSearchDashboardsResponseFactory, lo
// handle http response error of calling backend API
if (e.statusCode) {
if (e.statusCode >= 400 && e.statusCode <= 499) {
let message = typeof e.body === 'string' ? e.body : JSON.stringify(e.body);
if (!message) {
message = e.message;
}
return res.customError({
body: { message: typeof e.body === 'string' ? e.body : JSON.stringify(e.body) },
body: { message: message || 'unknow error' },
statusCode: e.statusCode,
});
} else {
Expand Down
13 changes: 7 additions & 6 deletions server/routes/summary_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ export function registerSummaryAssistantRoutes(
},
},
router.handleLegacyErrors(async (context, req, res) => {
const client = await getOpenSearchClientTransport({
context,
dataSourceId: req.query.dataSourceId,
});
const assistantClient = assistantService.getScopedClient(req, context);

try {
const client = await getOpenSearchClientTransport({
context,
dataSourceId: req.query.dataSourceId,
});

const assistantClient = assistantService.getScopedClient(req, context);

const insightAgentId = await detectInsightAgentId(
req.body.insightType,
req.body.summaryType,
Expand Down
Loading