Skip to content

fix(connections): Test Connection says why it failed (#1308) - #1323

Merged
ZhuchkaTriplesix merged 2 commits into
devfrom
fix/1308-test-connection-reason
Oct 10, 2026
Merged

ZhuchkaTriplesix merged 2 commits into
devfrom
fix/1308-test-connection-reason

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #1308

Problem

  • RedisConnection, MysqlConnection and MongoConnection.testConnection() returned bool; the forms showed failed and the mapped reason (Authentication failed, Cannot reach the database server, ...) was at most a debugPrint.
  • Worse, every form (PostgreSQL, SQLite too) rendered 'Connection failed' for any result that did not start with error:, so even the reason PostgreSQL returned was never shown.
  • The SQLite form's error: results were cut with substring(7) after a 6-character prefix: the first letter of the message was lost.

Fix

  • The three methods return ({bool ok, String? error}), with describeDatabaseError (as the PostgreSQL / SQLite ones do).
  • connection_test_result.dart: connectionTestMessage shows the reason (success / failed / error: ... / a reason), connectionTestResultLifetime keeps a reason on screen for 20 s (5 s for success). The five forms use them.

Tests: the message helper (incl. the SQLite prefix); RedisConnection.testConnection reports Authentication failed for a wrong password (tiny RESP server) and Cannot reach for a closed port; MysqlConnection.testConnection Cannot reach for a closed port. MongoDB is not driven in a unit test: the driver retries against a closed port for a long time.

- Redis, MySQL and MongoDB testConnection return the reason, in the same
  mapped words as PostgreSQL (Authentication failed..., Cannot reach...),
  not a bare bool.
- Every form showed 'Connection failed' for any result that did not start
  with 'error:', so the reason PostgreSQL and SQLite returned was dropped
  too. connectionTestMessage shows it, and a reason stays on screen for
  20 s instead of 5.
- The SQLite form's 'error:' text lost its first letter (substring(7)).
@github-actions github-actions Bot added bug Something isn't working error-handling Theme parser epic label: error-handling connections Database connections, URI parsing, pools ux User experience, keyboard shortcuts and interactions P2 Medium priority / Parity & Refactoring labels Oct 10, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit a7f87ec into dev Oct 10, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working connections Database connections, URI parsing, pools error-handling Theme parser epic label: error-handling P2 Medium priority / Parity & Refactoring ux User experience, keyboard shortcuts and interactions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant