Skip to content

Commit

Permalink
Updating catch for guardrails (opensearch-project#1631) (opensearch-p…
Browse files Browse the repository at this point in the history
…roject#1633)

* updating catch for guardrails

* removing osd config

* removing dismissible tag

---------

(cherry picked from commit 79faaeb)

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 0e6dd62)
  • Loading branch information
opensearch-trigger-bot[bot] authored and A9 Swift Project User committed Apr 9, 2024
1 parent ab35897 commit 8f01676
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions auto_sync_commit_metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"last_github_commit": "48646fd12532b1dbde109637938337c595c3835f",
"last_gitfarm_commit": "453c717f3b3300188b5afb8ba10ab871c7992607"
"last_github_commit": "0e6dd629b3cefcbe185530a6cc47f58e7c28757e",
"last_gitfarm_commit": "7f0f7bab2f10356dc93823855ddc9c4ba454410c"
}
2 changes: 1 addition & 1 deletion common/constants/query_assist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export const QUERY_ASSIST_API = {

export const ML_COMMONS_API_PREFIX = '/_plugins/_ml';

export const ERROR_DETAILS = { GUARDRAILS_TRIGGERED: 'guardrail triggered' };
export const ERROR_DETAILS = { GUARDRAILS_TRIGGERED: 'guardrails triggered' };
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const prohibitedQueryCallOut = (
size="s"
color="danger"
iconType="alert"
dismissible
/>
);

Expand All @@ -106,7 +105,6 @@ const emptyQueryCallOut = (
size="s"
color="warning"
iconType="iInCircle"
dismissible
/>
);

Expand All @@ -117,7 +115,6 @@ const pplGenerated = (
size="s"
color="success"
iconType="check"
dismissible
/>
);

Expand Down Expand Up @@ -200,7 +197,7 @@ export const QueryAssistInput: React.FC<React.PropsWithChildren<Props>> = (props
} as Error;
if (
error.body.statusCode === 400 &&
error.body.message === ERROR_DETAILS.GUARDRAILS_TRIGGERED
error.body.message.includes(ERROR_DETAILS.GUARDRAILS_TRIGGERED)
)
return new ProhibitedQueryError(error.body.message);
return error.body as Error;
Expand Down
4 changes: 2 additions & 2 deletions server/routes/query_assist/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function registerQueryAssistRoutes(router: IRouter) {
if (
isResponseError(error) &&
error.statusCode === 400 &&
error.body.error.details === ERROR_DETAILS.GUARDRAILS_TRIGGERED
error.body.includes(ERROR_DETAILS.GUARDRAILS_TRIGGERED)
) {
return response.badRequest({ body: ERROR_DETAILS.GUARDRAILS_TRIGGERED });
}
Expand Down Expand Up @@ -156,7 +156,7 @@ export function registerQueryAssistRoutes(router: IRouter) {
if (
isResponseError(error) &&
error.statusCode === 400 &&
error.body.error.details === ERROR_DETAILS.GUARDRAILS_TRIGGERED
error.body.includes(ERROR_DETAILS.GUARDRAILS_TRIGGERED)
) {
return response.badRequest({ body: ERROR_DETAILS.GUARDRAILS_TRIGGERED });
}
Expand Down

0 comments on commit 8f01676

Please sign in to comment.