[Fleet] Fix package policy name verification on update (#126356) (#126372)

(cherry picked from commit 43a2622b97)

Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
This commit is contained in:
Kibana Machine 2022-02-24 13:59:17 -05:00 committed by GitHub
parent 604ad8eb2c
commit cd88dc09b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -372,9 +372,10 @@ class PackagePolicyService {
}
// Check that the name does not exist already but exclude the current package policy
const existingPoliciesWithName = await this.list(soClient, {
perPage: 1,
kuery: `${PACKAGE_POLICY_SAVED_OBJECT_TYPE}.name: "${packagePolicy.name}"`,
perPage: SO_SEARCH_LIMIT,
kuery: `${PACKAGE_POLICY_SAVED_OBJECT_TYPE}.name:"${packagePolicy.name}"`,
});
const filtered = (existingPoliciesWithName?.items || []).filter((p) => p.id !== id);
if (filtered.length > 0) {