fix: Distinguish missing and empty plugin products (#15263)

Treat [] as no product allowed, empty as all products allowed.
This commit is contained in:
xl-openai
2026-03-19 20:02:40 -07:00
committed by GitHub
Unverified
parent a3e59e9e85
commit 35f8b87a5b
4 changed files with 183 additions and 29 deletions
+11 -7
View File
@@ -500,11 +500,14 @@ impl PluginsManager {
*stored_client = Some(analytics_events_client);
}
fn restriction_product_matches(&self, products: &[Product]) -> bool {
products.is_empty()
|| self
fn restriction_product_matches(&self, products: Option<&[Product]>) -> bool {
match products {
None => true,
Some([]) => false,
Some(products) => self
.restriction_product
.is_some_and(|product| product.matches_product_restriction(products))
.is_some_and(|product| product.matches_product_restriction(products)),
}
}
pub fn plugins_for_config(&self, config: &Config) -> PluginLoadOutcome {
@@ -830,7 +833,8 @@ impl PluginsManager {
.get(&plugin_key)
.map(|plugin| plugin.enabled);
let installed_version = self.store.active_plugin_version(&plugin_id);
let product_allowed = self.restriction_product_matches(&plugin.policy.products);
let product_allowed =
self.restriction_product_matches(plugin.policy.products.as_deref());
local_plugins.push((
plugin_name,
plugin_id,
@@ -991,7 +995,7 @@ impl PluginsManager {
if !seen_plugin_keys.insert(plugin_key.clone()) {
return None;
}
if !self.restriction_product_matches(&plugin.policy.products) {
if !self.restriction_product_matches(plugin.policy.products.as_deref()) {
return None;
}
@@ -1041,7 +1045,7 @@ impl PluginsManager {
marketplace_name,
});
};
if !self.restriction_product_matches(&plugin.policy.products) {
if !self.restriction_product_matches(plugin.policy.products.as_deref()) {
return Err(MarketplaceError::PluginNotFound {
plugin_name: request.plugin_name.clone(),
marketplace_name,