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:
trehanshakuntG
2025-09-26 00:07:07 +05:30
committed by GitHub
parent 58424a3f7f
commit 295f9dc41a
3 changed files with 10 additions and 4 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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{
{