Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ResponseOps] Throwing a mustache error when validating action message for warnings #158668

Merged
merged 2 commits into from May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -51,4 +51,8 @@ describe('validateParamsForWarnings', () => {
test('does not returns warnings when publicUrl is not set and the value is not a string', () => {
expect(validateParamsForWarnings(10, undefined, actionVariables)).toBeFalsy();
});

test('does not throw an error when passing in invalid mustache', () => {
expect(() => validateParamsForWarnings('{{', undefined, actionVariables)).not.toThrowError();
});
});
Expand Up @@ -31,14 +31,20 @@ export function validateParamsForWarnings(
return acc;
}, new Array<string>());

const variables = new Set(
(Mustache.parse(value) as Array<[string, string]>)
.filter(([type]) => type === 'name')
.map(([, v]) => v)
);
const hasUrlFields = some(publicUrlFields, (publicUrlField) => variables.has(publicUrlField));
if (hasUrlFields) {
return publicUrlWarning;
try {
const variables = new Set(
(Mustache.parse(value) as Array<[string, string]>)
.filter(([type]) => type === 'name')
.map(([, v]) => v)
);
const hasUrlFields = some(publicUrlFields, (publicUrlField) => variables.has(publicUrlField));
if (hasUrlFields) {
return publicUrlWarning;
}
} catch (e) {
/*
* do nothing, we don't care if the mustache is invalid
*/
}
}
return null;
Expand Down