Skip to content

Commit

Permalink
[Controls] Add Expensive Queries Fallback (#155082)
Browse files Browse the repository at this point in the history
## Summary
If the user has no permission to check for the value of `allow_expensive_queries`, it will now default to true instead of false.
  • Loading branch information
ThomThomson authored Apr 18, 2023
1 parent 5af2fd4 commit 66f68d4
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { getKbnServerError, reportServerError } from '@kbn/kibana-utils-plugin/server';
import { CoreSetup } from '@kbn/core/server';
import { errors } from '@elastic/elasticsearch';

export const setupOptionsListClusterSettingsRoute = ({ http }: CoreSetup) => {
const router = http.createRouter();
Expand Down Expand Up @@ -39,6 +40,17 @@ export const setupOptionsListClusterSettingsRoute = ({ http }: CoreSetup) => {
},
});
} catch (e) {
if (e instanceof errors.ResponseError && e.body.error.type === 'security_exception') {
/**
* in cases where the user does not have the 'monitor' permission this check will fail. In these cases, we will
* fall back to assume that the allowExpensiveQueries setting is on, because it defaults to true.
*/
return response.ok({
body: {
allowExpensiveQueries: true,
},
});
}
const kbnErr = getKbnServerError(e);
return reportServerError(response, kbnErr);
}
Expand Down

0 comments on commit 66f68d4

Please sign in to comment.