Skip to content

Fix incorrect error code for eval scripts and fix test error checking#10575

Merged
oranagra merged 5 commits intoredis:unstablefrom
madolson:weird-errors
Apr 14, 2022
Merged

Fix incorrect error code for eval scripts and fix test error checking#10575
oranagra merged 5 commits intoredis:unstablefrom
madolson:weird-errors

Conversation

@madolson
Copy link
Copy Markdown
Contributor

@madolson madolson commented Apr 12, 2022

By the convention of errors, there is supposed to be a space between the code and the name. While looking at some lua stuff I noticed that interpreter errors were not adding the space, so some clients will try to map the detailed error message into the error.

We have tests that hit this condition, but they were just checking that the string "starts" with ERR. I updated some other tests with similar incorrect string checking. This isn't complete though, as there are other ways we check for ERR I didn't fix.

Produces some fun output like:

# Errorstats
errorstat_ERR:count=1
errorstat_ERRuser_script_1_:count=1

@madolson madolson requested review from MeirShpilraien and yoav-steinberg and removed request for yoav-steinberg April 12, 2022 21:33
Comment thread tests/unit/type/hash.tcl
lappend rv [string match "ERR*not*float*" $smallerr]
lappend rv [string match "ERR*not*float*" $bigerr]
lappend rv [string match "ERR *not*float*" $smallerr]
lappend rv [string match "ERR *not*float*" $bigerr]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not certain I would bother to change all the places that checked the error without space.
It is indeed slightly better, but adds unnecessary changes to many places.
Maybe the main advantage is that if these lines will get copied, people will get the right thing.

What's bothering me more, is why don't we see some similar fix in scripting.tcl. That's the one that missed the issue you're fixing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because I forgot to commit the second half of the changes. I only captured the "ERR* and not {ERR*.

I'm going to posit it's still worth doing, since people are going to copy from these. There are no other mistakes, but I think it's good hygiene here.

Comment thread tests/integration/corrupt-dump-fuzzer.tcl Outdated
Comment thread src/function_lua.c
Copy link
Copy Markdown
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so the logic is that anything that just matches "ERR*" and no other text in the error message, can remain without a space, and everything that matches additional text after the error code, needs a space.

there are probably plenty of others matching specific error codes that are not ERR, like OOM, WRONGTYPE, but for these, it's usually enough to match just the error code, and i suppose no one bothered to match the error message.
i.e. we need to match the error message, just in cases where the error code is generic.

is all of that right?

@madolson
Copy link
Copy Markdown
Contributor Author

@oranagra That is my logic yes.

Copy link
Copy Markdown

@MeirShpilraien MeirShpilraien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks @madolson nice catch.

@oranagra oranagra merged commit effa707 into redis:unstable Apr 14, 2022
enjoy-binbin pushed a commit to enjoy-binbin/redis that referenced this pull request Jul 31, 2023
…redis#10575)

By the convention of errors, there is supposed to be a space between the code and the name.
While looking at some lua stuff I noticed that interpreter errors were not adding the space,
so some clients will try to map the detailed error message into the error.

We have tests that hit this condition, but they were just checking that the string "starts" with ERR.
I updated some other tests with similar incorrect string checking. This isn't complete though, as
there are other ways we check for ERR I didn't fix.

Produces some fun output like:
```
# Errorstats
errorstat_ERR:count=1
errorstat_ERRuser_script_1_:count=1
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants