Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 11cee1a

Browse files
clydinalan-agius4
authored andcommitted
fix(@angular/cli): correct boolean parsing in MCP example front matter
This commit fixes a bug in the `parseFrontmatter` utility where boolean values (true/false) were being incorrectly parsed as strings. The Zod schema validator for the `experimental` flag would reject these string values, causing the example database generation to fail. The parser has been updated to explicitly check for "true" and "false" strings and convert them to their corresponding boolean types, ensuring that the front matter is parsed correctly. This fix is applied to both the build-time database generator and the runtime tool.
1 parent 02d7105 commit 11cee1a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/angular/cli/src/commands/mcp/tools/examples.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,14 @@ function parseFrontmatter(content: string): Record<string, unknown> {
404404
isArray = value.trim() === '';
405405

406406
if (!isArray) {
407-
data[currentKey] = value.trim();
407+
const trimmedValue = value.trim();
408+
if (trimmedValue === 'true') {
409+
data[currentKey] = true;
410+
} else if (trimmedValue === 'false') {
411+
data[currentKey] = false;
412+
} else {
413+
data[currentKey] = trimmedValue;
414+
}
408415
}
409416
} else {
410417
const arrayItemMatch = line.match(/^\s*-\s*(.*)/);

tools/example_db_generator.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ function parseFrontmatter(content) {
4848
isArray = value.trim() === '';
4949

5050
if (!isArray) {
51-
data[currentKey] = value.trim();
51+
const trimmedValue = value.trim();
52+
if (trimmedValue === 'true') {
53+
data[currentKey] = true;
54+
} else if (trimmedValue === 'false') {
55+
data[currentKey] = false;
56+
} else {
57+
data[currentKey] = trimmedValue;
58+
}
5259
}
5360
} else {
5461
const arrayItemMatch = line.match(/^\s*-\s*(.*)/);

0 commit comments

Comments
 (0)