From dfb0144490a9c080baf1bed8ada8151608ffe180 Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Fri, 13 Jun 2025 15:40:17 +0200 Subject: [PATCH] src: enhance error messages for unknown options PR-URL: https://github.com/nodejs/node/pull/58677 Reviewed-By: Marco Ippolito Reviewed-By: Luigi Pinca Reviewed-By: Darshan Sen Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- 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 fa064ce6c91..00451cafc59 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 ea134ce1751..57824d16e4c 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); }); @@ -401,7 +401,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); });