Skip to content

Commit 932e4eb

Browse files
address copilot comments
1 parent 5d635aa commit 932e4eb

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

config/config.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,15 @@ func (c *ConfigType) AddTools(configs []plugins.ToolConfig) error {
191191
// Get the plugin manager to access tool configurations
192192
pluginManager := plugins.GetPluginManager()
193193

194-
// Resolve any legacy tool name aliases
195-
for i := range configs {
196-
if alias, ok := toolNameAliases[configs[i].Name]; ok {
197-
configs[i].Name = alias
194+
// Resolve any legacy tool name aliases on a copy to avoid mutating the caller's slice
195+
resolved := make([]plugins.ToolConfig, len(configs))
196+
copy(resolved, configs)
197+
for i := range resolved {
198+
if alias, ok := toolNameAliases[resolved[i].Name]; ok {
199+
resolved[i].Name = alias
198200
}
199201
}
202+
configs = resolved
200203

201204
// Ensure all required runtimes are present before processing tools
202205
for _, toolConfig := range configs {
@@ -267,6 +270,10 @@ func (c *ConfigType) AddTools(configs []plugins.ToolConfig) error {
267270

268271
// AddToolWithDefaultVersion adds a tool with its default version to the configuration
269272
func (c *ConfigType) AddToolWithDefaultVersion(toolName string) error {
273+
if alias, ok := toolNameAliases[toolName]; ok {
274+
toolName = alias
275+
}
276+
270277
// Get the default version for the tool from plugins
271278
defaultVersions := plugins.GetToolVersions()
272279
version, ok := defaultVersions[toolName]

0 commit comments

Comments
 (0)