googleapis/mcp-toolbox · error

unable to execute query: %w

Error message

unable to execute query: %w

What it means

Runtime failure wrap in Invoke: the underlying CockroachDB (pgx) connection returned an error when executing the tool's SQL statement. The wrapped error carries the driver's diagnosis, such as a syntax error, missing table, or connectivity failure.

Source

Thrown at internal/tools/cockroachdb/cockroachdbexecutesql/cockroachdbexecutesql.go:123

	source, ok := s.(compatibleSource)
	if !ok {
		return nil, util.NewClientServerError("source used is not compatible with the tool", http.StatusInternalServerError, nil)
	}
	paramsMap := params.AsMap()
	sql, ok := paramsMap["sql"].(string)
	if !ok {
		return nil, util.NewAgentError(fmt.Sprintf("parameter 'sql' is required, unable to cast %v", paramsMap["sql"]), nil)
	}

	logger, err := util.LoggerFromContext(ctx)
	if err != nil {
		return nil, util.NewClientServerError("error getting logger", http.StatusInternalServerError, err)
	}
	logger.DebugContext(ctx, fmt.Sprintf("executing `%s` tool query: %s", t.Cfg.Type, sql))

	results, err := source.Query(ctx, sql)
	if err != nil {
		return nil, util.ProcessGeneralError(fmt.Errorf("unable to execute query: %w", err))
	}
	defer results.Close()

	fields := results.FieldDescriptions()

	out := []any{}
	for results.Next() {
		v, err := results.Values()
		if err != nil {
			return nil, util.NewClientServerError("unable to parse row", http.StatusInternalServerError, err)
		}
		row := orderedmap.Row{}
		for i, f := range fields {
			row.Add(f.Name, v[i])
		}
		out = append(out, row)
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Read the wrapped driver error for the actual SQL failure (syntax, undefined relation, permissions)
  2. Verify the CockroachDB connection details and credentials in the source configuration
  3. If the statement is parameterized, pass the parameters instead of interpolating values
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/tools/cockroachdb/cockroachdbexecutesql/cockroachdbexecutesql.go:123 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/0546f94514abe938. Report an issue: GitHub.