From f022a130912d946d6f69af9cae3e374c60788ab3 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Mon, 30 Jun 2025 18:20:02 -0600 Subject: [PATCH] Add `#[serde(deny_unknown_fields)]` to action structs that didn't have it (#33679) Release Notes: - N/A --- crates/agent_ui/src/agent_ui.rs | 2 ++ crates/git/src/git.rs | 1 + crates/gpui/tests/action_macros.rs | 4 +++- crates/settings_ui/src/settings_ui.rs | 2 ++ crates/workspace/src/workspace.rs | 1 + crates/zed_actions/src/lib.rs | 7 +++++++ 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index 29a4f38487..0ba3d07f99 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -92,6 +92,7 @@ actions!( #[derive(Default, Clone, PartialEq, Deserialize, JsonSchema, Action)] #[action(namespace = agent)] +#[serde(deny_unknown_fields)] pub struct NewThread { #[serde(default)] from_thread_id: Option, @@ -99,6 +100,7 @@ pub struct NewThread { #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)] #[action(namespace = agent)] +#[serde(deny_unknown_fields)] pub struct ManageProfiles { #[serde(default)] pub customize_tools: Option, diff --git a/crates/git/src/git.rs b/crates/git/src/git.rs index bb8f39f127..d64d35b789 100644 --- a/crates/git/src/git.rs +++ b/crates/git/src/git.rs @@ -65,6 +65,7 @@ actions!( #[derive(Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Action)] #[action(namespace = git, deprecated_aliases = ["editor::RevertFile"])] +#[serde(deny_unknown_fields)] pub struct RestoreFile { #[serde(default)] pub skip_prompt: bool, diff --git a/crates/gpui/tests/action_macros.rs b/crates/gpui/tests/action_macros.rs index f601639fc8..7bff3a97b1 100644 --- a/crates/gpui/tests/action_macros.rs +++ b/crates/gpui/tests/action_macros.rs @@ -16,9 +16,11 @@ fn test_action_macros() { #[derive(PartialEq, Clone, Deserialize, JsonSchema, Action)] #[action(namespace = test_only)] - struct AnotherSomeAction; + #[serde(deny_unknown_fields)] + struct AnotherAction; #[derive(PartialEq, Clone, gpui::private::serde_derive::Deserialize)] + #[serde(deny_unknown_fields)] struct RegisterableAction {} register_action!(RegisterableAction); diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index b3fb10c5e6..28ffb1ab4a 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -31,6 +31,7 @@ impl FeatureFlag for SettingsUiFeatureFlag { #[derive(Copy, Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Action)] #[action(namespace = zed)] +#[serde(deny_unknown_fields)] pub struct ImportVsCodeSettings { #[serde(default)] pub skip_prompt: bool, @@ -38,6 +39,7 @@ pub struct ImportVsCodeSettings { #[derive(Copy, Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Action)] #[action(namespace = zed)] +#[serde(deny_unknown_fields)] pub struct ImportCursorSettings { #[serde(default)] pub skip_prompt: bool, diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 3853229243..7c5355bfd1 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -288,6 +288,7 @@ actions!( #[derive(Default, PartialEq, Eq, Clone, Deserialize, JsonSchema, Action)] #[action(namespace = file_finder, name = "Toggle")] +#[serde(deny_unknown_fields)] pub struct ToggleFileFinder { #[serde(default)] pub separate_history: bool, diff --git a/crates/zed_actions/src/lib.rs b/crates/zed_actions/src/lib.rs index b8c52e27e8..fa852084d6 100644 --- a/crates/zed_actions/src/lib.rs +++ b/crates/zed_actions/src/lib.rs @@ -58,6 +58,7 @@ pub enum ExtensionCategoryFilter { #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)] #[action(namespace = zed)] +#[serde(deny_unknown_fields)] pub struct Extensions { /// Filters the extensions page down to extensions that are in the specified category. #[serde(default)] @@ -66,6 +67,7 @@ pub struct Extensions { #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)] #[action(namespace = zed)] +#[serde(deny_unknown_fields)] pub struct DecreaseBufferFontSize { #[serde(default)] pub persist: bool, @@ -73,6 +75,7 @@ pub struct DecreaseBufferFontSize { #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)] #[action(namespace = zed)] +#[serde(deny_unknown_fields)] pub struct IncreaseBufferFontSize { #[serde(default)] pub persist: bool, @@ -80,6 +83,7 @@ pub struct IncreaseBufferFontSize { #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)] #[action(namespace = zed)] +#[serde(deny_unknown_fields)] pub struct ResetBufferFontSize { #[serde(default)] pub persist: bool, @@ -87,6 +91,7 @@ pub struct ResetBufferFontSize { #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)] #[action(namespace = zed)] +#[serde(deny_unknown_fields)] pub struct DecreaseUiFontSize { #[serde(default)] pub persist: bool, @@ -94,6 +99,7 @@ pub struct DecreaseUiFontSize { #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)] #[action(namespace = zed)] +#[serde(deny_unknown_fields)] pub struct IncreaseUiFontSize { #[serde(default)] pub persist: bool, @@ -101,6 +107,7 @@ pub struct IncreaseUiFontSize { #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)] #[action(namespace = zed)] +#[serde(deny_unknown_fields)] pub struct ResetUiFontSize { #[serde(default)] pub persist: bool,