googleapis/mcp-toolbox · error

unable to create connection pool: %w

Error message

unable to create connection pool: %w

What it means

Wrapped by initFirebirdConnectionPool when sql.Open("firebirdsql", dsn) fails. sql.Open validates driver registration and DSN format only; the dominant real-world cause is the firebirdsql driver never being registered via a blank import, followed by a malformed DSN string.

Source

Thrown at internal/sources/firebird/firebird.go:160

		return nil, fmt.Errorf("error iterating rows: %w", err)
	}

	// In most cases, DML/DDL statements like INSERT, UPDATE, CREATE, etc. might return no rows
	// However, it is also possible that this was a query that was expected to return rows
	// but returned none, a case that we cannot distinguish here.
	return out, nil
}

func initFirebirdConnectionPool(ctx context.Context, tracer trace.Tracer, name, host, port, user, pass, dbname string) (*sql.DB, error) {
	_, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)
	defer span.End()

	// urlExample := "user:password@host:port/path/to/database.fdb"
	dsn := fmt.Sprintf("%s:%s@%s:%s/%s", user, pass, host, port, dbname)

	db, err := sql.Open("firebirdsql", dsn)
	if err != nil {
		return nil, fmt.Errorf("unable to create connection pool: %w", err)
	}

	// Configure connection pool to prevent deadlocks
	db.SetMaxOpenConns(5)
	db.SetMaxIdleConns(2)
	db.SetConnMaxLifetime(5 * time.Minute)
	db.SetConnMaxIdleTime(1 * time.Minute)

	return db, nil
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Add/verify the blank import that registers the firebirdsql driver
  2. Escape special characters in user/password or switch to a DSN builder
  3. Log sql.Drivers() to confirm "firebirdsql" is registered before Open
  4. Validate config fields are non-empty before building the DSN

Example fix

// before
import (
    "database/sql"
)
db, err := sql.Open("firebirdsql", dsn)
// after
import (
    "database/sql"
    _ "github.com/mattn/go-firebirdsql"
)
db, err := sql.Open("firebirdsql", dsn)
Defensive patterns

Strategy: validation

Validate before calling

// Preflight: driver registered + DSN shape valid
func preflightFirebird(user, pass, host, port, dbname string) error {
    found := false
    for _, d := range sql.Drivers() {
        if d == "firebirdsql" { found = true }
    }
    if !found { return errors.New(`driver "firebirdsql" not registered; check blank import`) }
    if strings.ContainsAny(user+pass, ":@/") { return errors.New("unescaped special chars in credentials") }
    return nil
}

Type guard

func isOpenErrDriverMissing(err error) bool {
    return err != nil && strings.Contains(err.Error(), "unknown driver")
}

Try / catch

db, err := sql.Open("firebirdsql", dsn)
if err != nil {
    if isOpenErrDriverMissing(err) {
        return nil, fmt.Errorf("firebirdsql driver missing: %w", err)
    }
    return nil, fmt.Errorf("unable to create connection pool: %w", err)
}

Prevention

When it happens

Trigger: initFirebirdConnectionPool called with user:pass@host:port/dbname containing unescaped ':' '@' '/' characters, empty segments, or the "firebirdsql" driver name absent from sql.Drivers() because the package import was removed.

Common situations: Passwords with special characters; missing `import _ "github.com/mattn/go-firebirdsql"`-style registration; mistyped driver name; DSN assembled from empty config fields.

Related errors


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