Skip to content

Chrome DevTools for coding agents

fix(config): accept config files with a UTF-8 BOM (#3365)

Jae Bird63170b11a2fa
diff --git a/src/config/ConfigParser.ts b/src/config/ConfigParser.ts
index 03e861b4..834f343d 100644
--- a/src/config/ConfigParser.ts
+++ b/src/config/ConfigParser.ts
@@ -92,9 +92,10 @@ export class ConfigParser {
rawContent?: string,
): Partial<ParsedArguments> {
try {
- const fileContent: unknown = JSON.parse(
- rawContent ?? readFileSync(configPath, 'utf-8'),
- );
+ const content = rawContent ?? readFileSync(configPath, 'utf-8');
+ // Strip a leading UTF-8 byte order mark (U+FEFF). Windows PowerShell 5.1
+ // writes one by default, and JSON.parse rejects it.
+ const fileContent: unknown = JSON.parse(content.replace(/^\uFEFF/, ''));
if (!isPlainObject(fileContent)) {
throw new Error('Config must be a JSON object');
}
diff --git a/tests/config/mcp-options.test.ts b/tests/config/mcp-options.test.ts
index 01bbe1bf..b62f9490 100644
--- a/tests/config/mcp-options.test.ts
+++ b/tests/config/mcp-options.test.ts
@@ -68,6 +68,15 @@ describe('mcp-options steps', () => {
);
});
+ it('accepts a config file with a UTF-8 BOM', () => {
+ using configFile = createTempFile(
+ `\uFEFF${JSON.stringify({headless: true})}`,
+ 'cd4a.steps.config.bom.json',
+ );
+ const args = parser.parseConfigFile(configFile.path);
+ assert.strictEqual(args.headless, true);
+ });
+
it('accepts wsHeaders as a JSON object and validates string values', () => {
using validFile = createTempFile(
JSON.stringify({