向 SurrealDB 发送 `create` RPC 消息返回“数据库出现问题:表不存在”错误

Ste*_*hen 5 surrealdb surrealdb-rpc

我正在调试 .NET SurrealDB 库的一些测试。我可以很好地打开与数据库的连接,但是当我create向数据库(docker 容器)发送 RPC 消息时,它会返回一个错误,内容为“数据库出现问题:表不存在”

TRACE tungstenite::protocol Received message {"id":"02B70C1AFE5D","async":true,"method":"create","params":["users",{"username":"john","password":"test123"}]}
...
16 13:46:45] DEBUG surrealdb::dbs Executing: CREATE $what CONTENT $data RETURN AFTER

surreal_1  | [2022-09-16 13:46:45] TRACE surrealdb::dbs Iterating: CREATE $what CONTENT $data RETURN AFTER
Run Code Online (Sandbox Code Playgroud)

code: -32000, message: "There was a problem with the database: The table does not exist"

知道为什么会发生这种情况吗?当然,该表不存在,因为我正在尝试创建它。Surreal代码中是否还有其他原因会返回这样的错误?

Ste*_*hen 3

该错误消息是一个转移注意力的信息。实际问题是客户端出现错误,导致其无法正确登录,因此无权对数据库进行更改。

违规代码:

            // The table doesn't exist
            Err(Error::TbNotFound) => match opt.auth.check(Level::Db) {
                // We can create the table automatically
                true => {
                    run.add_and_cache_ns(opt.ns(), opt.strict).await?;
                    run.add_and_cache_db(opt.ns(), opt.db(), opt.strict).await?;
                    run.add_and_cache_tb(opt.ns(), opt.db(), &rid.tb, opt.strict).await
                }
                // We can't create the table so error
                false => Err(Error::TbNotFound), // Wrong Error Message
            },
Run Code Online (Sandbox Code Playgroud)

此问题已得到修复,如果客户端未经授权,现在应该返回查询权限错误。