diff --git a/crates/goose-server/src/routes/config_management.rs b/crates/goose-server/src/routes/config_management.rs index e21963a062..9dc2d0eb91 100644 --- a/crates/goose-server/src/routes/config_management.rs +++ b/crates/goose-server/src/routes/config_management.rs @@ -7,9 +7,9 @@ use axum::{ Json, Router, }; use etcetera::{choose_app_strategy, AppStrategy}; -use goose::config::Config; use goose::config::APP_STRATEGY; use goose::config::{extensions::name_to_key, PermissionManager}; +use goose::config::{Config, ConfigError}; use goose::config::{ExtensionConfigManager, ExtensionEntry}; use goose::model::ModelConfig; use goose::providers::base::ProviderMetadata; @@ -142,7 +142,7 @@ pub async fn remove_config( request_body = ConfigKeyQuery, responses( (status = 200, description = "Configuration value retrieved successfully", body = Value), - (status = 404, description = "Configuration key not found") + (status = 500, description = "Unable to get the configuration value"), ) )] pub async fn read_config( @@ -160,17 +160,24 @@ pub async fn read_config( } let config = Config::global(); - - match config.get(&query.key, query.is_secret) { + let response_value = match config.get(&query.key, query.is_secret) { Ok(value) => { if query.is_secret { - Ok(Json(Value::Bool(true))) + Value::Bool(true) } else { - Ok(Json(value)) + value } } - Err(_) => Err(StatusCode::NOT_FOUND), - } + Err(ConfigError::NotFound(_)) => { + if query.is_secret { + Value::Bool(false) + } else { + Value::Null + } + } + Err(_) => return Err(StatusCode::INTERNAL_SERVER_ERROR), + }; + Ok(Json(response_value)) } #[utoipa::path( diff --git a/ui/desktop/openapi.json b/ui/desktop/openapi.json index 39fa738298..f032e086b7 100644 --- a/ui/desktop/openapi.json +++ b/ui/desktop/openapi.json @@ -333,8 +333,8 @@ } } }, - "404": { - "description": "Configuration key not found" + "500": { + "description": "Unable to get the configuration value" } } } diff --git a/ui/desktop/src/api/types.gen.ts b/ui/desktop/src/api/types.gen.ts index bea406ee21..442ac0d247 100644 --- a/ui/desktop/src/api/types.gen.ts +++ b/ui/desktop/src/api/types.gen.ts @@ -1015,9 +1015,9 @@ export type ReadConfigData = { export type ReadConfigErrors = { /** - * Configuration key not found + * Unable to get the configuration value */ - 404: unknown; + 500: unknown; }; export type ReadConfigResponses = {