Skip to content

Commit

Permalink
Fix when field is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang committed Feb 5, 2021
1 parent c4d7ae1 commit c1b8dd1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions x-pack/plugins/fleet/server/services/epm/agent/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ password: {{password}}
{{#if password}}
hidden_password: {{password}}
{{/if}}
{{#if optional_field}}
optional_field: {{optional_field}}
{{/if}}
foo: {{bar}}
some_text_field: {{should_be_text}}
`;
const vars = {
paths: { value: ['/usr/local/var/log/nginx/access.log'] },
password: { type: 'password', value: '' },
optional_field: { type: 'text', value: undefined },
bar: { type: 'text', value: 'bar' },
should_be_text: { type: 'text', value: '1234' },
};
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/server/services/epm/agent/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function buildTemplateVariables(variables: PackagePolicyConfigRecord, templateSt
} else if (
recordEntry.type &&
recordEntry.type === 'text' &&
recordEntry.value.length &&
recordEntry.value?.length &&
!isNaN(+recordEntry.value)
) {
varPart[lastKeyPart] = `"${recordEntry.value}"`;
Expand Down

0 comments on commit c1b8dd1

Please sign in to comment.