From 2ebab366674988c9a76faf881b9c9b79f615435e Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Wed, 11 Jun 2025 15:19:25 +0200 Subject: [PATCH] src: enhance error messages for unknown options --- src/node_config_file.cc | 2 +- test/parallel/test-config-file.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node_config_file.cc b/src/node_config_file.cc index fa064ce6c913ab..00451cafc5951a 100644 --- a/src/node_config_file.cc +++ b/src/node_config_file.cc @@ -200,7 +200,7 @@ ParseResult ConfigReader::ParseOptions( } else { FPrintF(stderr, "Unknown or not allowed option %s for namespace %s\n", - option_key.data(), + option_key, namespace_name.c_str()); return ParseResult::InvalidContent; } diff --git a/test/parallel/test-config-file.js b/test/parallel/test-config-file.js index 0e67d12f09a02b..e5f02ed1bec946 100644 --- a/test/parallel/test-config-file.js +++ b/test/parallel/test-config-file.js @@ -154,7 +154,7 @@ test('should throw at unknown flag', async () => { fixtures.path('rc/unknown-flag.json'), '-p', '"Hello, World!"', ]); - match(result.stderr, /Unknown or not allowed option some-unknown-flag/); + match(result.stderr, /Unknown or not allowed option some-unknown-flag for namespace nodeOptions/); strictEqual(result.stdout, ''); strictEqual(result.code, 9); }); @@ -166,7 +166,7 @@ test('should throw at flag not available in NODE_OPTIONS', async () => { fixtures.path('rc/not-node-options-flag.json'), '-p', '"Hello, World!"', ]); - match(result.stderr, /Unknown or not allowed option test/); + match(result.stderr, /Unknown or not allowed option test for namespace nodeOptions/); strictEqual(result.stdout, ''); strictEqual(result.code, 9); }); @@ -398,7 +398,7 @@ describe('namespace-scoped options', () => { fixtures.path('rc/unknown-flag-namespace.json'), '-p', '"Hello, World!"', ]); - match(result.stderr, /Unknown or not allowed option unknown-flag/); + match(result.stderr, /Unknown or not allowed option unknown-flag for namespace testRunner/); strictEqual(result.stdout, ''); strictEqual(result.code, 9); });