t8y2/dbx · critical

%s connection failed

Error message

%s connection failed

What it means

openAndPingDB iterates over candidate SSL mode attempts; if every attempt fails it returns the underlying error immediately (line 572), so the generic 'vastbase connection failed' wrapper at line 574 is only reachable when the attempts slice is empty — i.e. the SSL mode configuration produced no attempt list at all. It signals that the driver never even tried to open a connection because the effective SSL mode was invalid or unhandled.

Source

Thrown at agents/drivers/vastbase-go/main.go:574

	sslMode := effectiveSSLMode(cp)
	attempts := agentSSLModeAttempts(sslMode)
	for index, attempt := range attempts {
		db, err := opener(cp, attempt)
		if err == nil {
			err = db.PingContext(ctx)
		}
		if err == nil {
			return db, nil
		}
		if db != nil {
			_ = db.Close()
		}
		if index == 0 && len(attempts) > 1 && agentSSLNotSupported(err) {
			continue
		}
		return nil, err
	}
	return nil, fmt.Errorf("%s connection failed", agentKey)
}

func openDBWithSSLMode(cp connectParams, sslMode string) (*sql.DB, error) {
	dsn := buildDSNWithSSLMode(cp, sslMode)
	db, err := sql.Open(agentSQLDriverName, dsn)
	if err != nil {
		return nil, err
	}
	// Each protocol session is serialized and owns one database connection.
	// Keeping a single physical connection preserves session state such as
	// search_path and avoids extra pool coordination on the hot query path.
	db.SetMaxOpenConns(1)
	db.SetMaxIdleConns(1)
	db.SetConnMaxLifetime(5 * time.Minute)
	return db, nil
}

func (s *server) disconnect() error {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Inspect the sslMode/sslmode value sent in connectParams and correct it to a mode the driver supports (e.g. disable, require, verify-ca, verify-full).
  2. Log or print effectiveSSLMode(cp) before connecting to confirm what the driver actually resolved from your parameters.
  3. Ensure an empty/missing sslMode falls back to the driver default rather than an unrecognized value.
  4. Check for trailing whitespace or wrong casing in config files or environment variables feeding the sslMode field.

Example fix

// before
params := connectParams{Host: "db", SSLMode: "required"} // unrecognized -> no attempts
// after
params := connectParams{Host: "db", SSLMode: "require"} // valid mode the driver maps to an attempt
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Calling connect/testConnection with an sslMode value that agentSSLModeAttempts does not recognize, yielding an empty attempts list so the for loop body never runs and control falls to the final return.

Common situations: Typo in the sslmode connection parameter (e.g. 'verify-ca ' with trailing whitespace, 'require' vs 'required'); an SSL mode supported by other Postgres-compatible drivers but not mapped in this driver; config file driving sslMode from an env var that is empty or misspelled.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/c348607f9d7ccc74. Report an issue: GitHub.