Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions crates/goose/src/agents/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use once_cell::sync::Lazy;
use rmcp::model::Tool;
use rmcp::service::ClientInitializeError;
use rmcp::ServiceError as ClientError;
use serde::Deserializer;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use tracing::warn;
Expand Down Expand Up @@ -215,7 +216,7 @@ pub enum ExtensionConfig {
Sse {
/// The name used to identify this extension
name: String,
#[serde(default)]
#[serde(deserialize_with = "deserialize_null_with_default")]
#[schema(required)]
description: String,
uri: String,
Expand All @@ -236,7 +237,7 @@ pub enum ExtensionConfig {
Stdio {
/// The name used to identify this extension
name: String,
#[serde(default)]
#[serde(deserialize_with = "deserialize_null_with_default")]
#[schema(required)]
description: String,
cmd: String,
Expand All @@ -256,7 +257,7 @@ pub enum ExtensionConfig {
Builtin {
/// The name used to identify this extension
name: String,
#[serde(default)]
#[serde(deserialize_with = "deserialize_null_with_default")]
#[schema(required)]
description: String,
display_name: Option<String>, // needed for the UI
Expand All @@ -271,7 +272,7 @@ pub enum ExtensionConfig {
Platform {
/// The name used to identify this extension
name: String,
#[serde(default)]
#[serde(deserialize_with = "deserialize_null_with_default")]
#[schema(required)]
description: String,
#[serde(default)]
Expand All @@ -284,7 +285,7 @@ pub enum ExtensionConfig {
StreamableHttp {
/// The name used to identify this extension
name: String,
#[serde(default)]
#[serde(deserialize_with = "deserialize_null_with_default")]
#[schema(required)]
description: String,
uri: String,
Expand All @@ -307,7 +308,7 @@ pub enum ExtensionConfig {
Frontend {
/// The name used to identify this extension
name: String,
#[serde(default)]
#[serde(deserialize_with = "deserialize_null_with_default")]
#[schema(required)]
description: String,
/// The tools provided by the frontend
Expand All @@ -324,7 +325,7 @@ pub enum ExtensionConfig {
InlinePython {
/// The name used to identify this extension
name: String,
#[serde(default)]
#[serde(deserialize_with = "deserialize_null_with_default")]
#[schema(required)]
description: String,
/// The Python code to execute
Expand Down Expand Up @@ -544,6 +545,15 @@ impl ExtensionInfo {
}
}

fn deserialize_null_with_default<'de, D, T>(deserializer: D) -> Result<T, D::Error>
where
T: Default + Deserialize<'de>,
D: Deserializer<'de>,
{
let opt = Option::deserialize(deserializer)?;
Ok(opt.unwrap_or_default())
}
Comment on lines +551 to +558
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deserialize_null_with_default function lacks documentation explaining its purpose and behavior. Consider adding a doc comment that clarifies it handles both null values and missing fields by defaulting to the type's default value, which is particularly important for the description String field that should default to an empty string.

Copilot uses AI. Check for mistakes.

/// Information about the tool used for building prompts
#[derive(Clone, Debug, Serialize, ToSchema)]
pub struct ToolInfo {
Expand Down
Loading