Extra help when config incorrect
Resolves https://github.com/edgedb/edgedb-cli/issues/1125 plus adds some extra help when database fails to connect.
(Redoing another PR that also went after the ._is_interactive() part which I see is recently added code)
In case of:
- Incorrect
user,password, ordatabase: adds hint to useedgedb infoto find config file location - Incorrect tls_cert_data: same message but nicer formatting to compare expected with actual
- Incorrect port: still hangs but adds message that the CLI will try for the timeout period (usually 30s),
- Incorrect tls_security: No change needed here as the message already lays out the file location and possible settings
Some before and afters:
Incorrect port
- Before
Connecting to EdgeDB instance 'anything' at localhost:11700...edgedb error: ClientConnectionFailedError: cannot establish connection for 30s: No connection could be made because the target machine actively refused it. (os error 10061)
- After
Connecting to EdgeDB instance 'anything' at localhost:11700 (will try up to 30s)... edgedb error: ClientConnectionFailedError: cannot establish connection for 30s: No connection could be made because the target machine actively refused it. (os error 10061)
Incorrect user
- Before
Connecting to EdgeDB instance 'anything' at localhost:10700...edgedb error: AuthenticationError: authentication failed Server traceback: Traceback (most recent call last): File "edb/server/protocol/frontend.pyx", line 338, in edb.server.protocol.frontend.FrontendConnection.main File "edb/server/protocol/binary.pyx", line 951, in authenticate File "edb/server/protocol/binary.pyx", line 285, in auth File "edb/server/protocol/frontend.pyx", line 574, in _authenticate File "edb/server/protocol/frontend.pyx", line 690, in _auth_scram edb.errors.AuthenticationError: authentication failed
- After
Connecting to EdgeDB instance 'anything' at localhost:10700 (will try up to 30s)...
Failed to authenticate.
Hint: Use edgedb info to find and check the config for this instance
edgedb error: AuthenticationError: authentication failed
Server traceback:
Traceback (most recent call last):
File "edb/server/protocol/frontend.pyx", line 338, in edb.server.protocol.frontend.FrontendConnection.main
File "edb/server/protocol/binary.pyx", line 951, in authenticate
File "edb/server/protocol/binary.pyx", line 285, in auth
File "edb/server/protocol/frontend.pyx", line 574, in _authenticate
File "edb/server/protocol/frontend.pyx", line 690, in _auth_scram
edb.errors.AuthenticationError: authentication failed
Incorrect password
- Before
Connecting to EdgeDB instance 'anything' at localhost:10700...edgedb error: AuthenticationError: authentication failed Server traceback: Traceback (most recent call last): File "edb/server/protocol/frontend.pyx", line 338, in edb.server.protocol.frontend.FrontendConnection.main File "edb/server/protocol/binary.pyx", line 951, in authenticate File "edb/server/protocol/binary.pyx", line 285, in auth File "edb/server/protocol/frontend.pyx", line 574, in _authenticate File "edb/server/protocol/frontend.pyx", line 690, in _auth_scram edb.errors.AuthenticationError: authentication failed
- After
Connecting to EdgeDB instance 'anything' at localhost:10700 (will try up to 30s)...
Failed to authenticate.
Hint: Use edgedb info to find and check the config for this instance
edgedb error: AuthenticationError: authentication failed
Server traceback:
Traceback (most recent call last):
File "edb/server/protocol/frontend.pyx", line 338, in edb.server.protocol.frontend.FrontendConnection.main
File "edb/server/protocol/binary.pyx", line 951, in authenticate
File "edb/server/protocol/binary.pyx", line 285, in auth
File "edb/server/protocol/frontend.pyx", line 574, in _authenticate
File "edb/server/protocol/frontend.pyx", line 690, in _auth_scram
edb.errors.AuthenticationError: authentication failed
Incorrect database
- Before
Connecting to EdgeDB instance 'anything' at localhost:10700...[2023-12-12T02:59:31Z WARN edgedb_tokio::raw::connection] Error received from server: database 'edgedbb' does not exist. Severity: Error. Code: 0x4030005 edgedb error: ClientConnectionFailedError: end of stream while reading message
- After
Connecting to EdgeDB instance 'anything' at localhost:10700 (will try up to 30s)... [2023-12-12T02:59:56Z WARN edgedb_tokio::raw::connection] Error received from server: database 'edgedbb' does not exist. Severity: Error. Code: 0x4030005 edgedb error: ClientConnectionFailedError: end of stream while reading message
Incorrect tls_cert_data
- Before
edgedb error: ClientError: cannot read credentials file C:\Users\mithr\AppData\Local\EdgeDB\config\credentials\anything.json: detected conflicting settings: tls_ca=Some("-----BEGIN CERTIFICATE-----\nMIIC0zCCAbugAwIBAgIRANoFby9jWEKWg+rIfBNbHxIwDQYJKoZIhvcNAQELBQAw\nGDEWMBQGA1UEAwwNRWRnZURCIFNlcnZlcjAeFw0yMzEyMDYyMTQxMjRaFw00MzAy\nMDUyMTQxMjRaMBgxFjAUBgNVBAMMDUVkZ2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EQiBTZXJ2ZXIwggEiMA0GCSqGSIb3\nDQEBAQUAA4IBDwAwggEKAoIBAQDqPb0sq6MVF4KCnrNisfzpSuigE8qd0vTIUqdj\ntsgyA534V/8jVCSlsy+LNDwEbwC8ChbuhyP65HgTmsdiiMkXHR3/E0g8POqLcm40\n24oTBqtRc4f8SOHHJThcxeLZ2WzgdvEjTJGhet/fR/8Gv4Fz8tClbqISfMkqHOVE\n5ViDKAtlpiGfDxfIrTBlHhuZM3BnD7o9yi+3zh7+aTHPVnbs2lxhh9O/Caa8TCUW\nsFocrEEijQRoIVmk3nzJ8goRZyIIBAY9g/OB06yW9LNGBbvHhNZyeKNQ7nnL8LMJ\nJ2Bpgbibp2itwFGZtrc1mnAnVNvx8CROnSpcQYTnh2AUEei9AgMBAAGjGDAWMBQG\nA1UdEQQNMAuCCWxvY2FsaG9zdDANBgkqhkiG9w0BAQsFAAOCAQEAELhVm4yRpvvG\nK0kyLsSSMZDwSXGbm4MiCFpRktJ04vo7o2j2OPwqxtjgNhmi7Xb8TUshD4dOWqU5\nrSzcGAtnqfCiLu6kqA9k2vfGSn/WiQb0ItpcqtyNQ3QqwOXju7wiTxGqjudhINuf\nXzSqZkBfpdAzpXG1e/PlKAepQ80Q9nP3j7dtmA3KbWDuJ+I1b4oOBNzhQZbXjsxH\n8uuY51TmnupI6TPu+KqVfln1Km5HlPeIKMrdoO0HVaU86+bBx+k0N0in1spOUCbz\nHdk0zWy2iYye2sMhtnsLDJysyIDOHEYTMoQ2XakuSiSOZmJvlCCFdrLF5jml5Ab8\nU9Q49+cuzQ==\n-----END CERTIFICATE-----\n")
- After
edgedb error: ClientError: cannot read credentials file C:\Users\mithr\AppData\Local\EdgeDB\config\credentials\anything.json: detected conflicting settings. tls_ca = Some( "-----BEGIN CERTIFICATE-----\nMIIC0zCCAbugAwIBAgIRANoFby9jWEKWg+rIfBNbHxIwDQYJKoZIhvcNAQELBQAw\nGDEWMBQGA1UEAwwNRWRnZURCIFNlcnZlcjAeFw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