Describe the bug
When trying to render a template in strict mode with an illegal include (something that generates the error 'include-denied'), mjml throws the following error:
/app/node_modules/mjml-core/lib/index.js:664
throw new ValidationError(`ValidationError: \n ${errors.map(e => e.formattedMessage).join('\n')}`, errors);
^
TypeError: Cannot read properties of null (reading 'formattedMessage')
at /app/node_modules/mjml-core/lib/index.js:664:76
at Array.map (<anonymous>)
at mjml2html (/app/node_modules/mjml-core/lib/index.js:664:65)
at mjml2html (/app/node_modules/mjml/lib/index.js:15:32)
at render (file:///app/build.js:215:44)
at processDir (file:///app/build.js:262:25)
at async file:///app/build.js:270:1
To Reproduce
Steps to reproduce the behavior:
- Create a set of three mjml files:
<!-- templates/problem.mjml -->
<mjml>
<mj-body>
<mj-include path="./common/problem2.mjml" />
</mj-body>
</mjml>
<!-- templates/common/problem2.mjml -->
<mjml>
<mj-body>
<mj-include path="../problem3.mjml" />
</mj-body>
</mjml>
<!-- templates/problem3.mjml -->
<mj-section>
<mj-column>
<mj-text>
Oh no!
</mj-text>
</mj-column>
</mj-section>
- Render it to HTML by doing:
import { readFileSync } from 'node:fs';
import mjml2html from 'mjml';
const filePath = './templates/problem.mjml';
const raw = readFileSync(filePath, { encoding: 'utf-8' });
await mjml2html(raw, {
filePath,
ignoreIncludes: false,
includePath: './templates',
validationLevel: 'strict',
});
- See error
Expected behavior
Rendering a template should not throw inside the error formatting logic.
MJML environment (please complete the following information):
- OS: macOS
- MJML Version: 5.4.0
- MJML tool used: mjml js api (
import mjml2html from 'mjml')
Email sending environment(for rendering issues):
N/A
Affected email clients (for rendering issues):
N/A
Screenshots
N/A
Additional context
N/A
Describe the bug
When trying to render a template in strict mode with an illegal include (something that generates the error
'include-denied'), mjml throws the following error:To Reproduce
Steps to reproduce the behavior:
Expected behavior
Rendering a template should not throw inside the error formatting logic.
MJML environment (please complete the following information):
import mjml2html from 'mjml')Email sending environment(for rendering issues):
N/A
Affected email clients (for rendering issues):
N/A
Screenshots
N/A
Additional context
N/A