[Cloud Security] Fix for console error message in rules benchmark page (#177887)

## Summary

Currently in Rules benchmark page, users seems to be getting error
message in their console (not affecting the UI).

This error is caused by malformed request to detection rule API and this
is due to us sending an empty Array. This is not a problem on other
component as in other component the API is called after users clicks to
open the component which will in turn fill in the array which means the
array is never empty. This is not the issue with this case as the API is
called even in the beginning

The solution in this PR is basically just giving default return value if
its ever empty
This commit is contained in:
Rickyanto Ang 2024-03-03 14:12:41 -08:00 committed by GitHub
parent 0bd29c9ef4
commit c1ccb1d3d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,9 +39,12 @@ export const useFetchDetectionRulesByTags = (
option: { match: 'all' | 'any' } = { match: 'all' }
) => {
const { http } = useKibana<CoreStart>().services;
return useQuery([DETECTION_ENGINE_RULES_KEY, tags, option], () =>
fetchDetectionRulesByTags(tags, option, http)
);
return useQuery({
queryKey: [DETECTION_ENGINE_RULES_KEY, tags, option],
queryFn: () => fetchDetectionRulesByTags(tags, option, http),
enabled: tags.length > 0,
});
};
export const fetchDetectionRulesByTags = (