Skip to content

Commit

Permalink
(query assist) extract ppl from error response
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Li <[email protected]>
  • Loading branch information
joshuali925 committed Jan 19, 2024
1 parent 8f1f83a commit 0e926c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export const QueryAssistInput: React.FC<Props> = (props) => {
},
})
);
if (explorerData.total > 0) generateSummary();
if (explorerData.total > 0 || summaryData.responseForSummaryStatus === 'failure')
generateSummary();
})();
}
}, [summaryData.responseForSummaryStatus]);
Expand Down
15 changes: 11 additions & 4 deletions server/routes/query_assist/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,17 @@ export function registerQueryAssistRoutes(router: IRouter, config: Observability
.replace(/\bSPAN\(/g, 'span('); // https://github.com/opensearch-project/dashboards-observability/issues/759
return response.ok({ body: ppl });
} catch (error) {
return response.custom({
statusCode: error.statusCode || 500,
body: error.message,
});
// parse PPL query from error response if exists
// TODO remove after https://github.com/opensearch-project/skills/issues/138
if (error.name === 'ResponseError') {
try {
const ppl = error.body.error.reason.match(/execute ppl:(.+), get error:/);
return response.ok({ body: ppl[1] });
} catch (parseError) {
return response.custom({ statusCode: error.statusCode || 500, body: error.message });
}
}
return response.custom({ statusCode: error.statusCode || 500, body: error.message });
}
}
);
Expand Down

0 comments on commit 0e926c8

Please sign in to comment.