{"record":{"id":"6b35fb25112839e8","repo":"googleapis/mcp-toolbox","slug":"error-updating-collection-w","errorCode":null,"errorMessage":"error updating collection: %w","messagePattern":"error updating collection: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/mongodb/mongodb.go","lineNumber":243,"sourceCode":"\t}\n\treturn res.InsertedID, nil\n}\n\nfunc (s *Source) UpdateMany(ctx context.Context, filterString string, canonical bool, updateString, database, collection string, upsert bool) ([]any, error) {\n\tvar filter = bson.D{}\n\terr := bson.UnmarshalExtJSON([]byte(filterString), canonical, &filter)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to unmarshal filter string: %w\", err)\n\t}\n\tvar update = bson.D{}\n\terr = bson.UnmarshalExtJSON([]byte(updateString), false, &update)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to unmarshal update string: %w\", err)\n\t}\n\n\tres, err := s.MongoClient().Database(database).Collection(collection).UpdateMany(ctx, filter, update, options.UpdateMany().SetUpsert(upsert))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error updating collection: %w\", err)\n\t}\n\treturn []any{res.ModifiedCount, res.UpsertedCount, res.MatchedCount}, nil\n}\n\nfunc (s *Source) UpdateOne(ctx context.Context, filterString string, canonical bool, updateString, database, collection string, upsert bool) (any, error) {\n\tvar filter = bson.D{}\n\terr := bson.UnmarshalExtJSON([]byte(filterString), false, &filter)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to unmarshal filter string: %w\", err)\n\t}\n\tvar update = bson.D{}\n\terr = bson.UnmarshalExtJSON([]byte(updateString), canonical, &update)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to unmarshal update string: %w\", err)\n\t}\n\n\tres, err := s.MongoClient().Database(database).Collection(collection).UpdateOne(ctx, filter, update, options.UpdateOne().SetUpsert(upsert))\n\tif err != nil {","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/mongodb/mongodb.go#L225-L261","documentation":"Error \"error updating collection: %w\" thrown in googleapis/mcp-toolbox.","triggerScenarios":"Thrown at internal/sources/mongodb/mongodb.go:243 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}