ember-optional-features icon indicating copy to clipboard operation
ember-optional-features copied to clipboard

Fix isFeatureEnabled to handle unknown features gracefully

Open Copilot opened this issue 3 months ago • 8 comments

Previously, calling isFeatureEnabled with an unknown feature name would throw "Cannot read properties of undefined (reading 'default')". This change makes isFeatureEnabled emit a warning and return null instead, preventing the exception.

Changes

  • index.js: Add guard in isFeatureEnabled to warn and return null for unknown features instead of throwing
  • tests/optional-features-test.js: Add test for isFeatureEnabled with unknown features

Behavior

When calling isFeatureEnabled('unknown-feature'):

Warning: Unknown feature "unknown-feature" passed to isFeatureEnabled

Returns null instead of throwing.

The original behavior for config file validation is preserved - unknown features in config/optional-features.json still throw an error as expected.

Original prompt

This addon throws an expection when a feature is set that it doesn't know about. Make it output a warning but not fail in that case.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot avatar Nov 25 '25 19:11 Copilot