denodrivers / denodrivers/mysql

`Error: Not supported` when trying to connect with wrong username

Open
#151 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
264
Forks
64
PR merge metrics
No merged PRs in 30d

Description

i have the following users setup in my mysql db
```
select * from mysql.user;
```
```
+-----------+------------------
| Host | User
+-----------+------------------
| localhost | debian-sys-maint
| localhost | mysql.infoschema
| localhost | mysql.session
| localhost | mysql.sys
| localhost | root
+-----------+------------------
```

when i now try to connect with a wrong non-existing user i get no error at all
```javascript
const client = await new Client().connect({
hostname: "127.0.0.1",
username: "testuser",
password: "Test12342",
});
```
when i then try to execute a sql query i get the following uninformative error message:
```
await client.execute(`CREATE DATABASE IF NOT EXISTS enok`);
```
```
error: Uncaught (in promise) Error: Not supported
throw new Error("Not supported");
^
at auth (https://deno.land/x/mysql@v2.11.0/src/auth.ts:41:13)
at PoolConnection._connect (https://deno.land/x/mysql@v2.11.0/src/connection.ts:118:24)
at async PoolConnection.connect (https://deno.land/x/mysql@v2.11.0/src/connection.ts:179:5)
at async Client.createConnection (https://deno.land/x/mysql@v2.11.0/src/client.ts:47:5)
at async DeferredStack.creator (https://deno.land/x/mysql@v2.11.0/src/pool.ts:67:20)
at async DeferredStack.pop (https://deno.land/x/mysql@v2.11.0/src/deferred.ts:35:16)
at async ConnectionPool.pop (https://deno.land/x/mysql@v2.11.0/src/pool.ts:99:14)
at async Client.useConnection (https://deno.land/x/mysql@v2.11.0/src/client.ts:105:24)
at async Client.execute (https://deno.land/x/mysql@v2.11.0/src/client.ts:96:12)
```
i would expect the following message
```
error: Uncaught (in promise) Error: Access denied for user 'testuser'@'localhost' (using password: YES)
```

i found out that this happens only for the strings 'testuser*' and 'root*', so for example username 'a_root' would give the correct error, or username 'a_testuser'

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/auth.ts at the reported line 41, then follow the connection flow through src/connection.ts. Reproduce the failure with username testuser or root and compare it with a_root; done means invalid usernames produce the expected access-denied error instead of "Not supported".

Written by the indexing model from the issue text.

Assessment

Tech stack
deno, mysql, typescript
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.