Describe the bug

When the EVAL method reply error, the monitoring indicators will be confused:

>  EVAL "return { err = '{\"code\": 40000}'}" 0
(error) {"code": 40000}

> info Errorstats
# Errorstats
errorstat_{"code"_:count=4

Expected behavior

I think the correct return should be:

> info Errorstats
# Errorstats
errorstat_ERR:count=1

No user message in Errorstats

Additional information I have tried it in the flow versions(both have problems): * 6.2.7 * 7.0

Comment From: jarpson

Lua error reply here: https://github.com/redis/redis/blob/6.2.11/src/scripting.c#L474

Comment From: enjoy-binbin

You may need to do this to return an error EVAL "return { err = 'ERR {\"code\": 40000}'}" 0

[root@binblog redis]# src/redis-cli
127.0.0.1:6379> info Errorstats
# Errorstats
127.0.0.1:6379> foo bar
(error) ERR unknown command 'foo', with args beginning with: 'bar' 
127.0.0.1:6379> info Errorstats
# Errorstats
errorstat_ERR:count=1
127.0.0.1:6379> EVAL "return { err = 'ERR {\"code\": 40000}'}" 0
(error) ERR {"code": 40000}
127.0.0.1:6379> info Errorstats
# Errorstats
errorstat_ERR:count=2

Comment From: jarpson

I think the error type is defined in the Redis system, and is it appropriate to define it in the script?

An extreme example:

EVAL "return { err = 'MOVED 6379 127.0.0.1' }" 0

User can return system error from script

Comment From: enjoy-binbin

i am pinging @MeirShpilraien, he may have more ideas :)

Comment From: yossigo

@jarpson Scripts are given enough power to control the error code returned rather than always enforcing -ERR. This is a feature, not a bug. The only issue here is that the documentation may need to be more elaborate and clear.

Comment From: enjoy-binbin

closing in favor of https://github.com/redis/redis-doc/pull/2382