mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-07 22:54:06 -05:00
chore: update toolset and promptset initialize failure log (#2039)
## Description Update error log to more details when initialization fails. * When a toolset name is not valid, show the toolset name (similar with promptset). * When tool does not exist, show the tool name that is missing (similar with prompt). ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [x] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #1579
This commit is contained in:
@@ -46,7 +46,7 @@ func (t PromptsetConfig) Initialize(serverVersion string, promptsMap map[string]
|
||||
var promptset Promptset
|
||||
promptset.Name = t.Name
|
||||
if !tools.IsValidName(promptset.Name) {
|
||||
return promptset, fmt.Errorf("invalid promptset name: %s", t)
|
||||
return promptset, fmt.Errorf("invalid promptset name: %s", promptset.Name)
|
||||
}
|
||||
promptset.Prompts = make([]*Prompt, 0, len(t.PromptNames))
|
||||
promptset.McpManifest = make([]McpManifest, 0, len(t.PromptNames))
|
||||
@@ -57,7 +57,7 @@ func (t PromptsetConfig) Initialize(serverVersion string, promptsMap map[string]
|
||||
for _, promptName := range t.PromptNames {
|
||||
prompt, ok := promptsMap[promptName]
|
||||
if !ok {
|
||||
return promptset, fmt.Errorf("prompt does not exist: %s", t)
|
||||
return promptset, fmt.Errorf("prompt does not exist: %s", promptName)
|
||||
}
|
||||
promptset.Prompts = append(promptset.Prompts, &prompt)
|
||||
promptset.Manifest.PromptsManifest[promptName] = prompt.Manifest()
|
||||
|
||||
@@ -46,9 +46,9 @@ func (t ToolsetConfig) Initialize(serverVersion string, toolsMap map[string]Tool
|
||||
var toolset Toolset
|
||||
toolset.Name = t.Name
|
||||
if !IsValidName(toolset.Name) {
|
||||
return toolset, fmt.Errorf("invalid toolset name: %s", t)
|
||||
return toolset, fmt.Errorf("invalid toolset name: %s", toolset.Name)
|
||||
}
|
||||
toolset.Tools = make([]*Tool, len(t.ToolNames))
|
||||
toolset.Tools = make([]*Tool, 0, len(t.ToolNames))
|
||||
toolset.Manifest = ToolsetManifest{
|
||||
ServerVersion: serverVersion,
|
||||
ToolsManifest: make(map[string]Manifest),
|
||||
@@ -56,7 +56,7 @@ func (t ToolsetConfig) Initialize(serverVersion string, toolsMap map[string]Tool
|
||||
for _, toolName := range t.ToolNames {
|
||||
tool, ok := toolsMap[toolName]
|
||||
if !ok {
|
||||
return toolset, fmt.Errorf("tool does not exist: %s", t)
|
||||
return toolset, fmt.Errorf("tool does not exist: %s", toolName)
|
||||
}
|
||||
toolset.Tools = append(toolset.Tools, &tool)
|
||||
toolset.Manifest.ToolsManifest[toolName] = tool.Manifest()
|
||||
|
||||
Reference in New Issue
Block a user