{"record":{"id":"c348607f9d7ccc74","repo":"t8y2/dbx","slug":"s-connection-failed","errorCode":null,"errorMessage":"%s connection failed","messagePattern":"(.+?) connection failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"agents/drivers/vastbase-go/main.go","lineNumber":574,"sourceCode":"\tsslMode := effectiveSSLMode(cp)\n\tattempts := agentSSLModeAttempts(sslMode)\n\tfor index, attempt := range attempts {\n\t\tdb, err := opener(cp, attempt)\n\t\tif err == nil {\n\t\t\terr = db.PingContext(ctx)\n\t\t}\n\t\tif err == nil {\n\t\t\treturn db, nil\n\t\t}\n\t\tif db != nil {\n\t\t\t_ = db.Close()\n\t\t}\n\t\tif index == 0 && len(attempts) > 1 && agentSSLNotSupported(err) {\n\t\t\tcontinue\n\t\t}\n\t\treturn nil, err\n\t}\n\treturn nil, fmt.Errorf(\"%s connection failed\", agentKey)\n}\n\nfunc openDBWithSSLMode(cp connectParams, sslMode string) (*sql.DB, error) {\n\tdsn := buildDSNWithSSLMode(cp, sslMode)\n\tdb, err := sql.Open(agentSQLDriverName, dsn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// Each protocol session is serialized and owns one database connection.\n\t// Keeping a single physical connection preserves session state such as\n\t// search_path and avoids extra pool coordination on the hot query path.\n\tdb.SetMaxOpenConns(1)\n\tdb.SetMaxIdleConns(1)\n\tdb.SetConnMaxLifetime(5 * time.Minute)\n\treturn db, nil\n}\n\nfunc (s *server) disconnect() error {","sourceCodeStart":556,"sourceCodeEnd":592,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/vastbase-go/main.go#L556-L592","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","Log or print effectiveSSLMode(cp) before connecting to confirm what the driver actually resolved from your parameters.","Ensure an empty/missing sslMode falls back to the driver default rather than an unrecognized value.","Check for trailing whitespace or wrong casing in config files or environment variables feeding the sslMode field."],"exampleFix":"// before\nparams := connectParams{Host: \"db\", SSLMode: \"required\"} // unrecognized -> no attempts\n// after\nparams := connectParams{Host: \"db\", SSLMode: \"require\"} // valid mode the driver maps to an attempt","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["connection","ssl","configuration","driver"],"backgroundTag":"ssl-mode-configuration-invalid","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}