googleapis/mcp-toolbox · error

unable to create connection: %w

Error message

unable to create connection: %w

What it means

Snowflake's Config.Initialize wraps initSnowflakeConnection errors with this message. This means constructing the snowflake driver connection (building the config/DSN from account, user, password, database, schema, warehouse, role) failed before any ping — typically invalid or missing connection parameters rather than a network failure. Initialization aborts and no source is registered.

Source

Thrown at internal/sources/snowflake/snowflake.go:66

	Name      string `yaml:"name" validate:"required"`
	Type      string `yaml:"type" validate:"required"`
	Account   string `yaml:"account" validate:"required"`
	User      string `yaml:"user" validate:"required"`
	Password  string `yaml:"password" validate:"required"`
	Database  string `yaml:"database" validate:"required"`
	Schema    string `yaml:"schema" validate:"required"`
	Warehouse string `yaml:"warehouse"`
	Role      string `yaml:"role"`
}

func (r Config) SourceConfigType() string {
	return SourceType
}

func (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {
	db, err := initSnowflakeConnection(ctx, tracer, r.Name, r.Account, r.User, r.Password, r.Database, r.Schema, r.Warehouse, r.Role)
	if err != nil {
		return nil, fmt.Errorf("unable to create connection: %w", err)
	}

	err = db.PingContext(ctx)
	if err != nil {
		db.Close()
		return nil, fmt.Errorf("unable to connect successfully: %w", err)
	}

	s := &Source{
		Config: r,
		DB:     db,
	}
	return s, nil
}

var _ sources.Source = &Source{}

type Source struct {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Verify the account identifier format: use <orgname>-<account_name> (e.g. myorg-myaccount), not a URL.
  2. Confirm account, user, and password are all set and non-empty in the source config.
  3. Check database, schema, warehouse, and role names exist in Snowflake (SHOW ROLES / SHOW WAREHOUSES).
  4. Read the wrapped driver error for the precise parameter problem.
  5. Test credentials with snowsql or the Snowflake web UI using the same values.

Example fix

// before
account: https://myorg-myacct.snowflakecomputing.com
// after
account: myorg-myacct
Defensive patterns

Strategy: validation

Validate before calling

// Validate Snowflake params before Initialize
func validateSnowflakeConfig(account, user, password string) error {
    if account == "" || user == "" || password == "" { return errors.New("account, user and password are required") }
    if strings.Contains(account, "snowflakecomputing.com") || strings.HasPrefix(account, "http") {
        return fmt.Errorf("account must be an identifier like 'org-account', got %q", account)
    }
    return nil
}

Try / catch

src, err := cfg.Initialize(ctx, tracer)
if err != nil && strings.Contains(err.Error(), "unable to create connection") {
    return fmt.Errorf("check account identifier (org-account) and credentials: %w", err)
}
// subsequent ping error handled separately

Prevention

When it happens

Trigger: Calling Initialize with an invalid account identifier format, empty required fields (account/user/password), or driver-level config validation failure (bad role, malformed account like including the full URL, unsupported auth configuration).

Common situations: Using the full account URL instead of the account identifier (e.g. "https://org-name.account.snowflakecomputing.com" instead of "orgname-accountname"), missing password for password auth, wrong region suffix format, or a role/warehouse name that doesn't exist caught at config build time.

Related errors


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