From f77d5e187cea156601d2d3b27b165f3d17e48ed7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 19:15:52 +0000 Subject: [PATCH 1/5] Initial plan From 31a0473777644e0bc4195364a5072fc2ce057786 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 19:18:18 +0000 Subject: [PATCH 2/5] Initial plan for changing unknown feature error to warning Co-authored-by: kategengler <444218+kategengler@users.noreply.github.com> --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1adbfe9..a0a53a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ember/optional-features", - "version": "2.0.0", + "version": "2.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@ember/optional-features", - "version": "2.0.0", + "version": "2.3.0", "license": "MIT", "dependencies": { "chalk": "^4.1.2", From 3d75c522d2a18a706561e8318ad81acaecd5e7cc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 19:20:19 +0000 Subject: [PATCH 3/5] Change unknown feature error to warning Co-authored-by: kategengler <444218+kategengler@users.noreply.github.com> --- index.js | 7 +++++-- tests/optional-features-test.js | 19 +++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index e144e76..74e8b1b 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ 'use strict'; const SilentError = require('silent-error'); +const chalk = require('chalk'); const FEATURES = require('./features'); const getConfigPath = require('./utils').getConfigPath; @@ -42,8 +43,10 @@ module.exports = { let keys = Object.keys(features); keys.forEach((key) => { if (FEATURES[key] === undefined) { - throw new SilentError( - `Unknown feature "${key}" found in config/optional-features.json` + console.warn( + chalk.yellow( + `Warning: Unknown feature "${key}" found in config/optional-features.json` + ) ); } else if (features[key] !== null && typeof features[key] !== 'boolean') { throw new SilentError( diff --git a/tests/optional-features-test.js b/tests/optional-features-test.js index 7744178..ed242d9 100644 --- a/tests/optional-features-test.js +++ b/tests/optional-features-test.js @@ -52,8 +52,23 @@ QUnit.module('@ember/optional-features', (hooks) => { return projectRoot.dispose(); }); - QUnit.test('it throws on invalid key', (assert) => { - assert.throws(() => buildAddon({ foo: true }), /Unknown feature "foo"/); + QUnit.test('it warns on invalid key', (assert) => { + let originalWarn = console.warn; + let warningMessage = null; + console.warn = (msg) => { + warningMessage = msg; + }; + try { + let addon = buildAddon({ foo: true }); + assert.ok( + warningMessage && warningMessage.includes('Unknown feature "foo"'), + 'Should warn about unknown feature' + ); + // The addon should still initialize successfully + assert.ok(addon.config, 'Addon should be initialized'); + } finally { + console.warn = originalWarn; + } }); QUnit.test('it throws on invalid value', (assert) => { From 6bcd4db0c2d5daa65158c1968be7bd3605f0fc8f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 19:58:52 +0000 Subject: [PATCH 4/5] Fix isFeatureEnabled to warn instead of throw for unknown features Co-authored-by: kategengler <444218+kategengler@users.noreply.github.com> --- index.js | 14 +++++++++++++- tests/optional-features-test.js | 23 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 74e8b1b..b088ac8 100644 --- a/index.js +++ b/index.js @@ -68,7 +68,19 @@ module.exports = { isFeatureEnabled(name) { let value = this._features[name]; - return value !== undefined ? value : FEATURES[name].default; + if (value !== undefined) { + return value; + } + let feature = FEATURES[name]; + if (feature === undefined) { + console.warn( + chalk.yellow( + `Warning: Unknown feature "${name}" passed to isFeatureEnabled` + ) + ); + return null; + } + return feature.default; }, isFeatureExplicitlySet(name) { diff --git a/tests/optional-features-test.js b/tests/optional-features-test.js index ed242d9..1b31bfc 100644 --- a/tests/optional-features-test.js +++ b/tests/optional-features-test.js @@ -165,6 +165,29 @@ QUnit.module('@ember/optional-features', (hooks) => { ); }); + QUnit.test( + 'it warns and returns null for unknown feature in isFeatureEnabled', + (assert) => { + let addon = buildAddon({}); + let originalWarn = console.warn; + let warningMessage = null; + console.warn = (msg) => { + warningMessage = msg; + }; + try { + let result = addon.isFeatureEnabled('unknown-feature'); + assert.strictEqual(result, null, 'Expecting null for unknown feature'); + assert.ok( + warningMessage && + warningMessage.includes('Unknown feature "unknown-feature"'), + 'Should warn about unknown feature' + ); + } finally { + console.warn = originalWarn; + } + } + ); + QUnit.test( 'it can query the features with `isFeatureExplicitlySet`', (assert) => { From 4514234d7c24abd7fa2181b3cd6e76ad0a86e742 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 20:23:21 +0000 Subject: [PATCH 5/5] Revert _validateFeatures change, keep only isFeatureEnabled fix Co-authored-by: kategengler <444218+kategengler@users.noreply.github.com> --- index.js | 6 ++---- tests/optional-features-test.js | 19 ++----------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index b088ac8..9d17079 100644 --- a/index.js +++ b/index.js @@ -43,10 +43,8 @@ module.exports = { let keys = Object.keys(features); keys.forEach((key) => { if (FEATURES[key] === undefined) { - console.warn( - chalk.yellow( - `Warning: Unknown feature "${key}" found in config/optional-features.json` - ) + throw new SilentError( + `Unknown feature "${key}" found in config/optional-features.json` ); } else if (features[key] !== null && typeof features[key] !== 'boolean') { throw new SilentError( diff --git a/tests/optional-features-test.js b/tests/optional-features-test.js index 1b31bfc..a054a40 100644 --- a/tests/optional-features-test.js +++ b/tests/optional-features-test.js @@ -52,23 +52,8 @@ QUnit.module('@ember/optional-features', (hooks) => { return projectRoot.dispose(); }); - QUnit.test('it warns on invalid key', (assert) => { - let originalWarn = console.warn; - let warningMessage = null; - console.warn = (msg) => { - warningMessage = msg; - }; - try { - let addon = buildAddon({ foo: true }); - assert.ok( - warningMessage && warningMessage.includes('Unknown feature "foo"'), - 'Should warn about unknown feature' - ); - // The addon should still initialize successfully - assert.ok(addon.config, 'Addon should be initialized'); - } finally { - console.warn = originalWarn; - } + QUnit.test('it throws on invalid key', (assert) => { + assert.throws(() => buildAddon({ foo: true }), /Unknown feature "foo"/); }); QUnit.test('it throws on invalid value', (assert) => {