mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-09 07:28:05 -05:00
fix(tools/mongodb): concat filter params only once in mongodb update tools (#1545)
## Description --- ### What Fixed a bug where `FilterParams` was being concatenated twice in the parameter list for MongoDB update operations. ### Why The duplicate concatenation would cause parameter validation to fail during tool initialization, preventing the MongoDB update tools from working. ### Changes - `mongodbupdateone.go`: Fixed `slices.Concat()` to properly combine FilterParams and UpdateParams - `mongodbupdatemany.go`: Fixed `slices.Concat()` to properly combine FilterParams and UpdateParams ## 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
This commit is contained in:
@@ -80,7 +80,7 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
}
|
||||
|
||||
// Create a slice for all parameters
|
||||
allParameters := slices.Concat(cfg.FilterParams, cfg.FilterParams, cfg.UpdateParams)
|
||||
allParameters := slices.Concat(cfg.FilterParams, cfg.UpdateParams)
|
||||
|
||||
// Verify no duplicate parameter names
|
||||
err := tools.CheckDuplicateParameters(allParameters)
|
||||
|
||||
@@ -81,7 +81,7 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
}
|
||||
|
||||
// Create a slice for all parameters
|
||||
allParameters := slices.Concat(cfg.FilterParams, cfg.FilterParams, cfg.UpdateParams)
|
||||
allParameters := slices.Concat(cfg.FilterParams, cfg.UpdateParams)
|
||||
|
||||
// Verify no duplicate parameter names
|
||||
err := tools.CheckDuplicateParameters(allParameters)
|
||||
|
||||
@@ -666,8 +666,14 @@ func getMongoDBToolsConfig(sourceConfig map[string]any, toolKind string) map[str
|
||||
"authRequired": []string{},
|
||||
"collection": "test_collection",
|
||||
"canonical": true,
|
||||
"filterPayload": `{ "id" : 300 }`,
|
||||
"filterParams": []any{},
|
||||
"filterPayload": `{ "id" : {{ .id }} }`,
|
||||
"filterParams": []map[string]any{
|
||||
{
|
||||
"name": "id",
|
||||
"type": "integer",
|
||||
"description": "id",
|
||||
},
|
||||
},
|
||||
"updatePayload": `{ "$set" : { "name": {{json .name}} } }`,
|
||||
"updateParams": []map[string]any{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user