Improve error message for duplicate package policies (#126170) (#126452)

(cherry picked from commit 2b8b331271)

# Conflicts:
#	x-pack/plugins/fleet/server/services/package_policy.ts
This commit is contained in:
Kyle Pollich 2022-02-28 09:05:06 -05:00 committed by GitHub
parent 633934ed32
commit 827e50d184
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -112,7 +112,9 @@ class PackagePolicyService {
// Check that the name does not exist already
if (existingPoliciesWithName.items.length > 0) {
throw new IngestManagerError('There is already an integration policy with the same name');
throw new IngestManagerError(
`An integration policy with the name ${packagePolicy.name} already exists. Please rename it or choose a different name.`
);
}
}
@ -379,7 +381,9 @@ class PackagePolicyService {
const filtered = (existingPoliciesWithName?.items || []).filter((p) => p.id !== id);
if (filtered.length > 0) {
throw new IngestManagerError('There is already an integration policy with the same name');
throw new IngestManagerError(
`An integration policy with the name ${packagePolicy.name} already exists. Please rename it or choose a different name.`
);
}
let inputs = restOfPackagePolicy.inputs.map((input) =>