Skip to content

Commit

Permalink
[7.17] [Fleet] fixed undefined error when missing policy vars in temp…
Browse files Browse the repository at this point in the history
…late (#124215) (#136324)

* [Fleet] fixed undefined error when missing policy vars in template (#124215)

* fixed undefined error when missing policy vars in template

* added validation error if input has no vars

* fixed checks

* added unit test

* fixed checks

* fixed checks

* fixed checks

* moved validation error to validatePackagePolicyConfig

(cherry picked from commit 67430f9)

# Conflicts:
#	x-pack/plugins/fleet/common/services/validate_package_policy.ts

* Fix duplicate test title

Co-authored-by: Julia Bardi <[email protected]>
  • Loading branch information
kpollich and juliaElastic authored Jul 13, 2022
1 parent acb9c5f commit 3504cc8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,7 @@ describe('Fleet - validatePackagePolicy()', () => {
});
});

// TODO enable when https://github.com/elastic/kibana/issues/125655 is fixed
it.skip('returns package policy validation error if input var does not exist', () => {
it('returns package policy validation error if input var does not exist', () => {
expect(
validatePackagePolicy(
{
Expand Down
14 changes: 9 additions & 5 deletions x-pack/plugins/fleet/common/services/validate_package_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,15 @@ export const validatePackagePolicyConfig = (
}

if (varDef === undefined) {
// TODO return validation error here once https://github.com/elastic/kibana/issues/125655 is fixed
// eslint-disable-next-line no-console
console.debug(`No variable definition for ${varName} found`);

return null;
errors.push(
i18n.translate('xpack.fleet.packagePolicyValidation.nonExistentVarMessage', {
defaultMessage: '{varName} var definition does not exist',
values: {
varName,
},
})
);
return errors;
}

if (varDef.required) {
Expand Down

0 comments on commit 3504cc8

Please sign in to comment.