Describe the bug.
The getTemplate function in apps/generator/lib/templates/bakedInTemplates.js does not handle the case where a template name does not exist in the baked-in templates list.
According to the JSDoc:
The function should return undefined when the template is not found.
However, when a non-existing template name is passed, the function throws a TypeError due to attempting to access .name on undefined.
Expected behavior
When a template is not found, the function should:
Either return undefined (as documented),
Or throw a meaningful, explicit error such as:
throw new Error(Core template "${templateName}" not found.);
It should not throw an unintended TypeError.
Screenshots
How to Reproduce
Navigate to:
generator/apps/generator/lib/templates
Start Node REPL:
node
Run:
const baked = require('./bakedInTemplates');
baked.getTemplate('this-template-does-not-exist');
Observe the crash:
TypeError: Cannot read properties of undefined (reading 'name')
🖥️ Device Information [optional]
- Operating System (OS):Windows11
- Browser:Brave
- Browser Version:
👀 Have you checked for similar open issues?
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue ?
Yes I am willing to submit a PR!
Describe the bug.
The
getTemplatefunction in apps/generator/lib/templates/bakedInTemplates.js does not handle the case where a template name does not exist in the baked-in templates list.According to the JSDoc:
The function should return
undefinedwhen the template is not found.However, when a non-existing template name is passed, the function throws a
TypeErrordue to attempting toaccess .nameon undefined.Expected behavior
When a template is not found, the function should:
Either return
undefined(as documented),Or throw a meaningful, explicit error such as:
throw new Error(Core template "${templateName}" not found.);It should not throw an unintended
TypeError.Screenshots
How to Reproduce
Navigate to:
generator/apps/generator/lib/templates
Start Node REPL:
node
Run:
const baked = require('./bakedInTemplates');
baked.getTemplate('this-template-does-not-exist');
Observe the crash:
TypeError: Cannot read properties of undefined (reading 'name')
🖥️ Device Information [optional]
👀 Have you checked for similar open issues?
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue ?
Yes I am willing to submit a PR!