{"record":{"id":"cd268e9d18c9a9d7","repo":"bytebase/bytebase","slug":"failed-to-build-snowflake-dsn","errorCode":null,"errorMessage":"failed to build Snowflake DSN","messagePattern":"failed to build Snowflake DSN","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/plugin/db/snowflake/snowflake.go","lineNumber":107,"sourceCode":"\t} else {\n\t\t// Use password authentication\n\t\tsnowConfig.Password = config.Password\n\t}\n\n\t// Host can also be account e.g. xma12345, or xma12345@host_ip where host_ip is the proxy server IP.\n\tif strings.Contains(config.DataSource.Host, \"@\") {\n\t\tparts := strings.Split(config.DataSource.Host, \"@\")\n\t\tif len(parts) != 2 {\n\t\t\treturn \"\", \"\", errors.Errorf(\"expected one @ in the host at most, got %q\", config.DataSource.Host)\n\t\t}\n\t\tsnowConfig.Account = parts[0]\n\t\tsnowConfig.Host = parts[1]\n\t} else {\n\t\tsnowConfig.Account = config.DataSource.Host\n\t}\n\tdsn, err := snow.DSN(snowConfig)\n\tif err != nil {\n\t\treturn \"\", \"\", errors.Wrapf(err, \"failed to build Snowflake DSN\")\n\t}\n\tsnowConfig.Password = \"xxxxxx\"\n\tif snowConfig.PrivateKey != nil {\n\t\tsnowConfig.PrivateKey = nil\n\t}\n\tredactedDSN, err := snow.DSN(snowConfig)\n\tif err != nil {\n\t\t// nolint\n\t\tslog.Warn(\"failed to build redacted Snowflake DSN\", log.BBError(err))\n\t\treturn dsn, \"\", nil\n\t}\n\treturn dsn, redactedDSN, nil\n}\n\n// Close closes the driver.\nfunc (d *Driver) Close(context.Context) error {\n\treturn d.db.Close()\n}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/plugin/db/snowflake/snowflake.go#L89-L125","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the wrapped inner error — snow.DSN's message identifies which parameter was rejected.","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.","Confirm required instance fields (account/host, user) are non-empty and that database/warehouse names, if set, are valid Snowflake identifiers.","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."],"exampleFix":"// before\nHost: \"https://acct123.snowflakecomputing.com/\"\n// after\nHost: \"acct123\"  // snow.DSN rejects URL-shaped hosts","handlingStrategy":"try-catch","validationCode":"// pre-validate account shape\nif strings.Contains(host, \"//\") || strings.Contains(host, \"/\") {\n    return errors.New(\"host must not be a URL; use the bare account identifier\")\n}","typeGuard":"func looksLikeURL(s string) bool { return strings.HasPrefix(s, \"http\") || strings.Contains(s, \"/\") }","tryCatchPattern":"dsn, err := snow.DSN(cfg)\nif err != nil {\n    return fmt.Errorf(\"DSN rejected (check account format and required fields): %w\", err)\n}","preventionTips":["Use Snowflake's documented account identifier format without scheme or path","Keep user and required fields non-empty","Test the same parameters with snowsql or the Go driver directly"],"tags":["snowflake","dsn","driver","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}