Add `#[serde(deny_unknown_fields)]` to action structs that didn't have it (#33679)

Michael Sloan created

Release Notes:

- N/A

Change summary

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(-)

Detailed changes

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<ThreadId>,
@@ -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<AgentProfileId>,

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,

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);

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,

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,

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,