Repository navigation
Add development feature toggle system - #6719
Conversation
|
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. |
agners
left a comment
There was a problem hiding this comment.
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 👍 !
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>
b8a7fd4 to
f799d7c
Compare
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>
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>
There was a problem hiding this comment.
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) andATTR_FEATURE_FLAGSconstant for defining and persisting toggles. - Extends Supervisor config validation and persistence to store
feature_flagsinconfig.json. - Extends Supervisor REST API:
GET /supervisor/inforeturns all known feature flags with their current state.POST /supervisor/optionssupports partial updates tofeature_flagsand 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. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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_apiwhich will gate the upcoming V2 API.API Changes
POST /supervisor/optionsAccepts a
feature_flagsdict. 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/infoAlways returns all known feature flags and their current state for discoverability:
{"feature_flags": {"supervisor_v2_api": false}}Implementation
FeatureFlagStrEnum insupervisor/const.py— add new toggles here as an enum valuefeature_flagsstored inconfig.jsonas a dict, defaults toFalsefor any flag not yet setFeatureFlagenum valuesAdditional information