dolthub / dolthub/dolt

Error differences when running CLI commands locally vs against a server

Open
#6,307 0 comments 0 reactions 0 assignees View on GitHub
bug cli
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 5h
Merged PRs (30d)
108

Description

Below is a bats test which is a slight modification of `integration-tests/bats/sql-shell.bats` that demonstrates that the error messages returned by GMS vary depending on the context they are run in.

In this particular place, the message generated by SQLEngine is more generic than the DB access forbidden status returned by the server.

SQLEngine Check fails here: https://github.com/dolthub/go-mysql-server/blob/d3613a9b66654e384df9c4e2f123c08c1ec07a78/sql/analyzer/privileges.go#L54

Sql Server check fails here: https://github.com/dolthub/go-mysql-server/blob/d3613a9b66654e384df9c4e2f123c08c1ec07a78/sql/mysql_db/privileged_database_provider.go#L66

I'm not familiar with the GMS authorization code path at all, but it seems like we are performing different authorization checks depending on the context.

```
@test "sql-shell: use user without privileges, and no superuser created" {
rm -rf .doltcfg

# default user is root
run dolt sql <<< "select user from mysql.user"
[ "$status" -eq 0 ]
[[ "$output" =~ "root" ]] || false

# create user
run dolt sql <<< "create user new_user@'localhost'"
[ "$status" -eq 0 ]

run dolt --user=new_user sql <<< "select user from mysql.user"
[ "$status" -eq 1 ]
if [ "$SQL_ENGINE" = "remote-engine" ]; then
[[ "$output" =~ "Access denied for user 'new_user'@'localhost'" ]] || false
else
[[ "$output" =~ "command denied to user 'new_user'@'localhost'" ]] || false
fi

rm -rf .doltcfg
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.