bytebase/bytebase · error

failed to build Snowflake DSN

Error message

failed to build Snowflake DSN

What it means

buildSnowflakeDSN (backend/plugin/db/snowflake/snowflake.go:107) wraps errors returned by the go-snowflake-driver's snow.DSN(snowConfig) as 'failed to build Snowflake DSN'. This means the individual config fields (account, host, user, warehouse, database, etc.) were accepted structurally but the driver's DSN serializer rejected the combination — typically an invalid or mutually inconsistent parameter value.

Source

Thrown at backend/plugin/db/snowflake/snowflake.go:107

	} else {
		// Use password authentication
		snowConfig.Password = config.Password
	}

	// Host can also be account e.g. xma12345, or xma12345@host_ip where host_ip is the proxy server IP.
	if strings.Contains(config.DataSource.Host, "@") {
		parts := strings.Split(config.DataSource.Host, "@")
		if len(parts) != 2 {
			return "", "", errors.Errorf("expected one @ in the host at most, got %q", config.DataSource.Host)
		}
		snowConfig.Account = parts[0]
		snowConfig.Host = parts[1]
	} else {
		snowConfig.Account = config.DataSource.Host
	}
	dsn, err := snow.DSN(snowConfig)
	if err != nil {
		return "", "", errors.Wrapf(err, "failed to build Snowflake DSN")
	}
	snowConfig.Password = "xxxxxx"
	if snowConfig.PrivateKey != nil {
		snowConfig.PrivateKey = nil
	}
	redactedDSN, err := snow.DSN(snowConfig)
	if err != nil {
		// nolint
		slog.Warn("failed to build redacted Snowflake DSN", log.BBError(err))
		return dsn, "", nil
	}
	return dsn, redactedDSN, nil
}

// Close closes the driver.
func (d *Driver) Close(context.Context) error {
	return d.db.Close()
}

View on GitHub (pinned to 1870550677)

Solutions

  1. Read the wrapped inner error — snow.DSN's message identifies which parameter was rejected.
  2. Verify the account identifier matches Snowflake's format (e.g. 'xy12345.us-east-1' or 'orgname-account_name') and contains no scheme or path characters.
  3. Confirm required instance fields (account/host, user) are non-empty and that database/warehouse names, if set, are valid Snowflake identifiers.
  4. Try connecting with the same parameters via the SnowSQL/Go driver directly to isolate whether the values or the Bytebase config mapping are at fault.

Example fix

// before
Host: "https://acct123.snowflakecomputing.com/"
// after
Host: "acct123"  // snow.DSN rejects URL-shaped hosts
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-validate account shape
if strings.Contains(host, "//") || strings.Contains(host, "/") {
    return errors.New("host must not be a URL; use the bare account identifier")
}

Type guard

func looksLikeURL(s string) bool { return strings.HasPrefix(s, "http") || strings.Contains(s, "/") }

Try / catch

dsn, err := snow.DSN(cfg)
if err != nil {
    return fmt.Errorf("DSN rejected (check account format and required fields): %w", err)
}

Prevention

When it happens

Trigger: Calling Open/TestConnection on a Snowflake datasource where snow.DSN fails, e.g. an invalid account locator format, an empty required field the driver requires in the DSN, or a parameter value containing characters the driver rejects when serializing the DSN string.

Common situations: Account identifiers with disallowed characters or the full 'orgname-account' form mishandled; empty host with non-default region expectations; special characters in database/warehouse names not properly handled; driver version incompatibility with a config field shape.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06). Data as JSON: /api/errors/cd268e9d18c9a9d7. Report an issue: GitHub.