From 5388fa406ed9db586e901bf27980db03ed89389f Mon Sep 17 00:00:00 2001 From: l5z12 Date: Fri, 2 Oct 2026 02:05:16 +0800 Subject: [PATCH] feat(config): allow unsupported client feature flags --- .env.template | 5 +++++ src/api/core/mod.rs | 6 +++++- src/config.rs | 51 ++++++++++++++++++++++++++++++++++++++++++++- src/util.rs | 1 - 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/.env.template b/.env.template index 62231776..aa6d43e1 100644 --- a/.env.template +++ b/.env.template @@ -411,6 +411,11 @@ ## - "enable-basic-auth-response": Enable HTTP Basic Auth autofill in the browser extension (Browser >= 2026.9.0) # EXPERIMENTAL_CLIENT_FEATURE_FLAGS= +## Allow flags in EXPERIMENTAL_CLIENT_FEATURE_FLAGS that are not in the supported list above. +## When enabled, all listed flags are sent to clients and unsupported flags do not block configuration updates. +## Unsupported flags remain visible in admin diagnostics and may require functionality Vaultwarden does not provide. +# EXPERIMENTAL_CLIENT_FEATURE_FLAGS_ALLOW_UNSUPPORTED=false + ## Require new device emails. When a user logs in an email is required to be sent. ## If sending the email fails the login attempt will fail!! # REQUIRE_DEVICE_EMAIL=false diff --git a/src/api/core/mod.rs b/src/api/core/mod.rs index e6a184dd..56ce36c7 100644 --- a/src/api/core/mod.rs +++ b/src/api/core/mod.rs @@ -217,7 +217,11 @@ fn config() -> Json { // iOS (v2026.2.1): https://github.com/bitwarden/ios/blob/cdd9ba1770ca2ffc098d02d12cc3208e3a830454/BitwardenShared/Core/Platform/Models/Enum/FeatureFlag.swift#L7 let mut feature_states = parse_experimental_client_feature_flags( &CONFIG.experimental_client_feature_flags(), - &FeatureFlagFilter::ValidOnly, + &if CONFIG.experimental_client_feature_flags_allow_unsupported() { + FeatureFlagFilter::Unfiltered + } else { + FeatureFlagFilter::ValidOnly + }, ); feature_states.insert("pm-19148-innovation-archive".to_owned(), true); diff --git a/src/config.rs b/src/config.rs index 9f0ae2e1..a30698fc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -723,6 +723,9 @@ make_config! { /// Customize the enabled feature flags on the clients |> This is a comma separated list of feature flags to enable. experimental_client_feature_flags: String, false, def, String::new(); + /// Allow unsupported client feature flags |> Pass all configured experimental client feature flags to clients, including flags outside the supported list. + /// Unsupported flags remain visible in admin diagnostics and may require functionality Vaultwarden does not provide. + experimental_client_feature_flags_allow_unsupported: bool, false, def, false; /// Require new device emails |> When a user logs in an email is required to be sent. /// If sending the email fails the login attempt will fail. @@ -1066,7 +1069,7 @@ fn validate_config(cfg: &ConfigItems, on_update: bool) -> Result<(), Error> { &cfg.experimental_client_feature_flags, &FeatureFlagFilter::InvalidOnly, ); - if !invalid_flags.is_empty() { + if !cfg.experimental_client_feature_flags_allow_unsupported && !invalid_flags.is_empty() { let feature_flags_error = format!( "Unrecognized experimental client feature flags: {invalid_flags:?}.\n\ Please ensure all feature flags are spelled correctly and that they are supported in this version.\n\ @@ -1873,3 +1876,49 @@ handlebars::handlebars_helper!(webver: | web_vault_version: String | handlebars::handlebars_helper!(vwver: | vw_version: String | semver::VersionReq::parse(&vw_version).expect("Invalid Vaultwarden version compare string").matches(&VW_VERSION) ); + +#[cfg(test)] +mod tests { + use super::{ConfigBuilder, validate_config}; + + fn config_with_unsupported_feature_flag() -> ConfigBuilder { + ConfigBuilder { + database_url: Some("sqlite://feature-flags-test.sqlite3".to_owned()), + experimental_client_feature_flags: Some("unsupported-test-feature".to_owned()), + ..ConfigBuilder::default() + } + } + + #[test] + fn unsupported_feature_flags_are_rejected_on_update_by_default() { + let config = config_with_unsupported_feature_flag().build(); + + assert!(!config.experimental_client_feature_flags_allow_unsupported); + assert!(validate_config(&config, false).is_ok()); + let error = validate_config(&config, true).unwrap_err(); + assert!(error.to_string().contains("Unrecognized experimental client feature flags")); + } + + #[test] + fn unsupported_feature_flags_can_be_allowed_on_startup_and_update() { + let mut builder = config_with_unsupported_feature_flag(); + builder.experimental_client_feature_flags_allow_unsupported = Some(true); + let config = builder.build(); + + assert!(validate_config(&config, false).is_ok()); + assert!(validate_config(&config, true).is_ok()); + } + + #[test] + fn allowing_unsupported_feature_flags_preserves_other_validation() { + let mut builder = config_with_unsupported_feature_flag(); + builder.experimental_client_feature_flags_allow_unsupported = Some(true); + builder.smtp_security = Some("invalid-security".to_owned()); + let config = builder.build(); + + for on_update in [false, true] { + let error = validate_config(&config, on_update).unwrap_err(); + assert!(error.to_string().contains("SMTP_SECURITY")); + } + } +} diff --git a/src/util.rs b/src/util.rs index 6de2d803..043b6a7c 100644 --- a/src/util.rs +++ b/src/util.rs @@ -815,7 +815,6 @@ pub fn convert_json_key_lcase_first(src_json: Value) -> Value { } pub enum FeatureFlagFilter { - #[allow(dead_code)] Unfiltered, ValidOnly, InvalidOnly,