Skip to content

Conversation

Copy link

Copilot AI commented Nov 25, 2025

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 AI and others added 2 commits November 25, 2025 19:18
Co-authored-by: kategengler <444218+kategengler@users.noreply.github.com>
Co-authored-by: kategengler <444218+kategengler@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix exception handling for unknown features in addon Emit warning instead of error for unknown optional features Nov 25, 2025
Copilot AI requested a review from kategengler November 25, 2025 19:23
Copilot finished work on behalf of kategengler November 25, 2025 19:23
@kategengler
Copy link
Member

@copilot That's not the bug. If someone puts an unknown feature in the config file, it throws an exception unexpectedly

Copy link
Author

Copilot AI commented Nov 25, 2025

@copilot That's not the bug. If someone puts an unknown feature in the config file, it throws an exception unexpectedly

The current implementation does exactly that - when an unknown feature is found in the config file, it now outputs a warning message and continues instead of throwing an exception. The addon initializes successfully and processes any known features normally.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • google-analytics.com
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/ember-optional-features/ember-optional-features/node_modules/.bin/ember feature (dns block)
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/ember-optional-features/ember-optional-features/node_modules/.bin/ember feature:list (dns block)
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/ember-optional-features/ember-optional-features/node_modules/.bin/ember feature:enable application-template-wrapper (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of kategengler November 25, 2025 19:53
@kategengler
Copy link
Member

@copilot It fails when an unknown feature is checked with isFeatureEnabled

Co-authored-by: kategengler <444218+kategengler@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 25, 2025

@copilot It fails when an unknown feature is checked with isFeatureEnabled

Fixed in 6bcd4db. The isFeatureEnabled method now warns and returns null for unknown features instead of throwing "Cannot read properties of undefined (reading 'default')".

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • google-analytics.com
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/ember-optional-features/ember-optional-features/node_modules/.bin/ember feature (dns block)
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/ember-optional-features/ember-optional-features/node_modules/.bin/ember feature:list (dns block)
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/ember-optional-features/ember-optional-features/node_modules/.bin/ember feature:enable application-template-wrapper (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of kategengler November 25, 2025 20:01
@kategengler
Copy link
Member

@copilot That was the fix we needed. Undo the earlier change.

Co-authored-by: kategengler <444218+kategengler@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 25, 2025

@copilot That was the fix we needed. Undo the earlier change.

Done in 4514234. Reverted the _validateFeatures change - unknown features in config file now throw as before. Only the isFeatureEnabled fix remains.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • google-analytics.com
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/ember-optional-features/ember-optional-features/node_modules/.bin/ember feature (dns block)
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/ember-optional-features/ember-optional-features/node_modules/.bin/ember feature:list (dns block)
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/ember-optional-features/ember-optional-features/node_modules/.bin/ember feature:enable application-template-wrapper (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Emit warning instead of error for unknown optional features Fix isFeatureEnabled to handle unknown features gracefully Nov 25, 2025
Copilot finished work on behalf of kategengler November 25, 2025 20:25
@kategengler
Copy link
Member

@copilot rebase and make it one commit

Copy link
Author

Copilot AI commented Nov 25, 2025

@copilot rebase and make it one commit

I'm unable to perform interactive rebasing or force pushing in this environment. You'll need to squash the commits when merging the PR, or I can help you with the squash commit message if needed.

Copilot finished work on behalf of kategengler November 25, 2025 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants