fix: explicitly set query location for BigQuery queries (#586)

For issue https://github.com/googleapis/genai-toolbox/issues/567

---------

Co-authored-by: Yuan <45984206+Yuan325@users.noreply.github.com>
This commit is contained in:
Huan Chen
2025-05-20 15:07:43 -07:00
committed by GitHub
parent 8dec385538
commit eb52b66d82
2 changed files with 2 additions and 1 deletions

View File

@@ -121,6 +121,7 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues) ([]any, erro
query := t.Client.Query(t.Statement)
query.Parameters = namedArgs
query.Location = t.Client.Location
it, err := query.Read(ctx)
if err != nil {

View File

@@ -123,7 +123,7 @@ func TestBigQueryToolEndpoints(t *testing.T) {
select1Want := "[{\"f0_\":1}]"
// Partial message; the full error message is too long.
failInvocationWant := `{"jsonrpc":"2.0","id":"invoke-fail-tool","result":{"content":[{"type":"text","text":"unable to execute query: googleapi: Error 400: Syntax error: Unexpected identifier \"SELEC\" at [1:1], invalidQuery"}],"isError":true}}`
failInvocationWant := `{"jsonrpc":"2.0","id":"invoke-fail-tool","result":{"content":[{"type":"text","text":"unable to execute query: googleapi: Error 400: Syntax error: Unexpected identifier \"SELEC\" at [1:1]`
invokeParamWant, mcpInvokeParamWant := tests.GetNonSpannerInvokeParamWant()
tests.RunToolInvokeTest(t, select1Want, invokeParamWant)
tests.RunMCPToolCallMethod(t, mcpInvokeParamWant, failInvocationWant)