From ab85a4f534344e501fe3ddaa41bd6fa92f37d896 Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Mon, 20 Jul 2026 13:07:41 -0600 Subject: [PATCH] feat: validate unique client names at config load --- src/config/mod.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 8b607ec..6cdebd1 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -44,7 +44,7 @@ pub use self::skill_registry::SkillRegistry; pub use self::update::run_self_update; use crate::client::{ ClientConfig, MessageContentToolCalls, Model, ModelType, OPENAI_COMPATIBLE_PROVIDERS, - ProviderModels, create_client_config, list_client_types, + ProviderModels, create_client_config, list_client_types, oauth, }; use crate::function::{FunctionDeclaration, Functions}; use crate::rag::Rag; @@ -596,6 +596,18 @@ impl Config { }) .with_context(|| "Failed to load config from str")?; + let mut seen = std::collections::HashSet::new(); + for cc in &config.clients { + let (name, _, _) = oauth::client_config_info(cc); + if !seen.insert(name.to_string()) { + bail!( + "Duplicate client name '{name}' in config.yaml. \ + Client names must be unique across all `clients[]` entries \ + to avoid OAuth token collisions." + ); + } + } + Ok(config) }