Skip to content

Add development feature toggle system - #6719

Merged
agners merged 4 commits into
mainfrom
feature-toggles
Apr 15, 2026
Merged

agners merged 4 commits into
mainfrom
feature-toggles

Conversation

@mdegat01

@mdegat01 mdegat01 commented Apr 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a feature toggle system to Supervisor to gate features during development, preventing users from depending on in-flux APIs.

The first toggle is supervisor_v2_api which will gate the upcoming V2 API.

API Changes

POST /supervisor/options

Accepts a feature_flags dict. Only keys present are changed — absent keys leave the current state unchanged, consistent with Supervisor's existing partial-update pattern.

{"feature_flags": {"supervisor_v2_api": true}}

Unknown feature flag names are rejected with a 400 error.

GET /supervisor/info

Always returns all known feature flags and their current state for discoverability:

{"feature_flags": {"supervisor_v2_api": false}}

Implementation

  • FeatureFlag StrEnum in supervisor/const.py — add new toggles here as an enum value
  • feature_flags stored in config.json as a dict, defaults to False for any flag not yet set
  • Voluptuous schema validates keys against FeatureFlag enum values

Additional information

@mdegat01 mdegat01 added the new-feature A new feature label Apr 9, 2026
@mdegat01

mdegat01 commented Apr 9, 2026

Copy link
Copy Markdown
Member Author

So first thing I realized with the v2 API is I want us to be able to iterate on it for a bit. And I don't want to block Supervisor releases until its ready to ship to make changing what we have a breaking change. So I thought a feature toggle setup would be a good idea. Then we can continue to ship versions of Supervisor as normal while freely changing V2 until its ready without worrying about breaking others.

@mdegat01
mdegat01 requested a review from agners April 9, 2026 04:23

@agners agners left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the naming nit, I think this is a good idea. In a way it mirrors a bit the lab approach we have in Core. The incremental development approach works much better for us, and having the feature behind a flag helps us avoid features being used while they are work-in-progress. Nice 👍 !

Comment thread supervisor/api/supervisor.py Resolved
@mdegat01 mdegat01 added missing-documentation Added to pull requests that needs a docs, but none is linked needs-cli Pull requests needs CLI changes but none is linked needs-client-library Pull requests needs client library changes but none is linked labels Apr 14, 2026
mdegat01 and others added 2 commits April 14, 2026 17:54
Introduces an ExperimentalFeature enum and feature_flags config to allow
toggling experimental features via the supervisor options API. The first
feature flag is 'supervisor_v2_api' to gate the upcoming V2 API.

Absent keys in options request = no change (partial update, consistent
with existing options APIs). The info endpoint always returns all known
feature flags and their current state for discoverability.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mdegat01 mdegat01 changed the title Add experimental feature toggle system Add development feature toggle system Apr 14, 2026
@mdegat01 mdegat01 removed needs-client-library Pull requests needs client library changes but none is linked labels Apr 14, 2026
mdegat01 added a commit to home-assistant/developers.home-assistant that referenced this pull request Apr 14, 2026
Document the new feature_flags field in /supervisor/info (returns all known
development feature flags and their current state) and /supervisor/options
(allows partial updates to feature flags).

Related: home-assistant/supervisor#6719

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mdegat01 mdegat01 removed missing-documentation Added to pull requests that needs a docs, but none is linked labels Apr 14, 2026
mdegat01 added a commit to home-assistant/cli that referenced this pull request Apr 14, 2026
Allows users to enable/disable development feature flags via:
  ha supervisor options --feature-flag supervisor_v2_api=true
  ha supervisor options --feature-flag supervisor_v2_api  (defaults to true)
  ha supervisor options --feature-flag supervisor_v2_api=false

Multiple flags can be set by repeating the argument. Tab completion
calls /supervisor/info and suggests each flag with its opposite value
(e.g. supervisor_v2_api=true when currently false).

Related: home-assistant/supervisor#6719

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mdegat01 mdegat01 removed needs-cli Pull requests needs CLI changes but none is linked labels Apr 14, 2026
@agners agners added the api-v2 PR which is related to API v2 changes. label Apr 15, 2026
@agners
agners requested a review from Copilot April 15, 2026 07:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a development feature-flag mechanism to Home Assistant Supervisor so in-progress capabilities (starting with the upcoming V2 API) can be explicitly gated and discovered via the Supervisor REST API.

Changes:

  • Introduces FeatureFlag (StrEnum) and ATTR_FEATURE_FLAGS constant for defining and persisting toggles.
  • Extends Supervisor config validation and persistence to store feature_flags in config.json.
  • Extends Supervisor REST API:
    • GET /supervisor/info returns all known feature flags with their current state.
    • POST /supervisor/options supports partial updates to feature_flags and rejects unknown flag names.
  • Adds API tests covering info exposure, enable/disable, partial-update behavior, and unknown-flag rejection.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
supervisor/const.py Adds ATTR_FEATURE_FLAGS and FeatureFlag enum for declaring toggles.
supervisor/validate.py Extends SCHEMA_SUPERVISOR_CONFIG to validate/persist feature_flags.
supervisor/config.py Adds config accessors/mutators for feature flag storage.
supervisor/api/supervisor.py Adds API schema support for feature_flags; exposes all flags in /supervisor/info; applies updates in /supervisor/options.
tests/api/test_supervisor.py Adds test coverage for feature flag API behavior and validation.

Comment thread supervisor/api/supervisor.py Resolved
Comment thread tests/api/test_supervisor.py Resolved
Comment thread supervisor/config.py Resolved
agners and others added 2 commits April 15, 2026 10:05
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@agners agners left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM!

@agners
agners merged commit 1218326 into main Apr 15, 2026
19 checks passed
@agners
agners deleted the feature-toggles branch April 15, 2026 11:13
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api-v2 PR which is related to API v2 changes. cla-signed new-feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants