Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ After installing a [Gemini CLI extensions](https://geminicli.com/extensions/), t
gemini

# List extensions
/exttensions list
/extensions list
# List MCP servers
/mcp list
```
Expand Down
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ require (
github.com/neo4j/neo4j-go-driver/v6 v6.0.0
github.com/redis/go-redis/v9 v9.18.0
github.com/sijms/go-ora/v2 v2.9.0
github.com/snowflakedb/gosnowflake v1.19.1
github.com/snowflakedb/gosnowflake/v2 v2.0.1
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/testcontainers/testcontainers-go v0.42.0
Expand Down Expand Up @@ -117,7 +117,6 @@ require (
github.com/ajg/form v1.5.1 // indirect
github.com/apache/arrow-go/v18 v18.4.0 // indirect
github.com/apache/arrow/go/v15 v15.0.2 // indirect
github.com/apache/thrift v0.22.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.41.5 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.8 // indirect
github.com/aws/aws-sdk-go-v2/config v1.31.8 // indirect
Expand Down Expand Up @@ -200,7 +199,6 @@ require (
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/klauspost/asmfmt v1.3.2 // indirect
github.com/klauspost/compress v1.18.5 // indirect
github.com/klauspost/cpuid/v2 v2.2.11 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
Expand All @@ -209,8 +207,6 @@ require (
github.com/magiconair/properties v1.8.10 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/go-archive v0.2.0 // indirect
github.com/moby/moby/api v1.54.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ github.com/sijms/go-ora/v2 v2.9.0 h1:+iQbUeTeCOFMb5BsOMgUhV8KWyrv9yjKpcK4x7+MFrg
github.com/sijms/go-ora/v2 v2.9.0/go.mod h1:QgFInVi3ZWyqAiJwzBQA+nbKYKH77tdp1PYoCqhR2dU=
github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=
github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g=
github.com/snowflakedb/gosnowflake v1.19.1 h1:NZMErtdZMu6kooehbONNQmu/W5BPsaX8hYdlBBEHgxs=
github.com/snowflakedb/gosnowflake v1.19.1/go.mod h1:9vGW6LYbUD1UqfjpuNN5a5vtha+u4n1AlsR1BqhHwPA=
github.com/snowflakedb/gosnowflake/v2 v2.0.1 h1:zRHCluGtwFLpc1wzN/T3U2GdWd11dx4/LeLgZBjxHvU=
github.com/snowflakedb/gosnowflake/v2 v2.0.1/go.mod h1:c0hIqJ/dxgaMl7g1o8n4Ca3Mf5YCiiVx9igio/PNqC8=
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
Expand Down
2 changes: 1 addition & 1 deletion internal/sources/snowflake/snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/goccy/go-yaml"
"github.com/googleapis/mcp-toolbox/internal/sources"
"github.com/jmoiron/sqlx"
_ "github.com/snowflakedb/gosnowflake"
_ "github.com/snowflakedb/gosnowflake/v2"
"go.opentelemetry.io/otel/trace"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, para

dryRunJob, err := bqutil.DryRunQuery(ctx, restService, bqClient.Project(), bqClient.Location, sql, nil, connProps, source.GetMaximumBytesBilled())
if err != nil {
return nil, util.NewClientServerError("query validation failed", http.StatusInternalServerError, err)
return nil, util.ProcessGcpError(err)
}

statementType := dryRunJob.Statistics.Query.StatementType
Expand Down
64 changes: 64 additions & 0 deletions internal/util/errors_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2026 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package util

import (
"errors"
"net/http"
"testing"

"google.golang.org/api/googleapi"
)

func TestProcessGcpErrorTreatsBadRequestAsAgentError(t *testing.T) {
err := ProcessGcpError(&googleapi.Error{
Code: http.StatusBadRequest,
Message: "Bad Request",
Errors: []googleapi.ErrorItem{{
Reason: "invalidQuery",
Message: "No matching signature for operator >=",
}},
})

var agentErr *AgentError
if !errors.As(err, &agentErr) {
t.Fatalf("expected AgentError, got %T", err)
}
}

func TestProcessGcpErrorPreservesAuthFailuresAsServerErrors(t *testing.T) {
tcs := []struct {
name string
code int
}{
{name: "unauthorized", code: http.StatusUnauthorized},
{name: "forbidden", code: http.StatusForbidden},
}

for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
err := ProcessGcpError(&googleapi.Error{
Code: tc.code,
Message: http.StatusText(tc.code),
})

var clientServerErr *ClientServerError
if !errors.As(err, &clientServerErr) {
t.Fatalf("expected ClientServerError, got %T", err)
}
if clientServerErr.Code != tc.code {
t.Fatalf("expected code %d, got %d", tc.code, clientServerErr.Code)
}
})
}
}
6 changes: 2 additions & 4 deletions tests/bigquery/bigquery_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1003,8 +1003,7 @@ func runBigQueryExecuteSqlToolInvokeTest(t *testing.T, select1Want, invokeParamW
api: "http://127.0.0.1:5000/api/tool/my-exec-sql-tool/invoke",
requestHeader: map[string]string{},
requestBody: bytes.NewBuffer([]byte(`{"sql":"CREATE TABLE t (id SERIAL PRIMARY KEY, name TEXT)"}`)),
want: ddlWant,
isErr: true,
want: `{"error":"error processing GCP request: failed to insert dry run job: googleapi: Error 400: Table \"t\" must be qualified with a dataset (e.g. dataset.table)., invalid"}`,
},
{
name: "invoke my-exec-sql-tool with data present in table",
Expand All @@ -1027,8 +1026,7 @@ func runBigQueryExecuteSqlToolInvokeTest(t *testing.T, select1Want, invokeParamW
api: "http://127.0.0.1:5000/api/tool/my-exec-sql-tool/invoke",
requestHeader: map[string]string{},
requestBody: bytes.NewBuffer([]byte(`{"sql":"DROP TABLE t"}`)),
want: ddlWant,
isErr: true,
want: `{"error":"error processing GCP request: failed to insert dry run job: googleapi: Error 400: Table \"t\" must be qualified with a dataset (e.g. dataset.table)., invalid"}`,
},
{
name: "invoke my-exec-sql-tool insert entry",
Expand Down
2 changes: 1 addition & 1 deletion tests/snowflake/snowflake_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/googleapis/mcp-toolbox/internal/testutils"
"github.com/googleapis/mcp-toolbox/tests"
"github.com/jmoiron/sqlx"
_ "github.com/snowflakedb/gosnowflake"
_ "github.com/snowflakedb/gosnowflake/v2"
)

var (
Expand Down
Loading