New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drivers overusing ReqlDriverError #4669
Comments
Does this overlap with #4646 or supercede it? |
branch: larkost/4669-ReqlDriverError-prep codereview: 3144
branch: larkost/4669-ReqlDriverError-prep codereview: 3144
#4646 seems to cover the first checkbox of this. |
👍 I agree for all of these (i.e. think that they should be
|
I disagree with this because a ReqlResourceLimitError inherits from ReqlRuntimeError, which indicates that it was returned by the server. I do not think that a driver should be raising a ReqlRuntimeError on its own. As you said, it is a driver/language-specific limitation, so it should probably remain a ReqlDriverError. |
I don't think any of these should return I do agree that we should probably distinguish these errors from other "the driver is buggy" |
@mlucy Well the whole premise of this proposal is that users don't care whether something has reached the server or not. Arity errors for example are sometimes caught in the driver, and sometimes on the server. For the user, that doesn't make the slightest difference. |
To add to that, I think we have a pretty big hierarchy, there doesn't seem to be a reason to double it to distinguish server/driver errors in building the query |
I agree that arity errors shouldn't be
Errors like "you exceeding the arbitrary nesting depth for |
Aside from the intellectual argument that the errors are different, it's really useful to know what component you need to blame for an error. For example, if you're using a third-party driver and you write code that you think is correct but which produces a driver error, you know that you should open a bug with the driver maintainer rather than in the main RethinkDB repo. If it produces a compilation error, though, you know that the server is rejecting it, so you know that you should open a bug in the main RethinkDB repo and/or try upgrading your server. |
Actually, probably the way we should handle this is to have two subclasses of compilation error: |
-1 for new exceptions |
Specifically, I don't think solving this issue should involve creating new exception types |
I actually think subclassing In practice users will not need to care about this distinction. If some code needs to handle (usually probably log/report and then fail) compilation errors, it can just keep catching |
Yeah, thinking about it more I think my favorite solution is breaking |
Since exceptions are part of the protocol, we should have a really compelling use case for adding new ones. The reason to have an exception class is because you need to programmatically distinguish between types of errors and handle some of them automatically. For determining where you need to file a bug, you just look at the stack trace in your logs, so the error message is enough. No one is going to automatically file a bug report from their app. My recommendation is to add something like "(client detected error)" to the exception messages thrown by the driver, or distinguish them in some way in the message, rather than by adding a new exception to the protocol. |
I really don't think the cost of adding a new exception type is that high, and the distinction seems important to me. I also disagree that exception types only exist to allow for programmatic handling of different errors: types are for humans as well as machines. But even if we accepted that premise, there are probably about as many reasons to distinguish ReQL driver errors from ReQL server errors as there are to distinguish ReQL compilation errors from ReQL runtime errors. For example, you may want to log them at different priority levels, or send an email to your DBAs for one class of error or to whoever maintains your app deployment for the other (since one class of error can be caused by RethinkDB being out of date and the other can be caused by your driver being out of date). For another example, you may be generating queries based on user input, where compilation errors on the server can be caused by the user making a mistake but driver errors (like misuse of infix operators) can only be caused by your program being wrong. (Assuming we change things so that arity errors aren't detected by the client.) |
Of your suggested use-cases above, which of those can't be used to justify the creation of any new exception class? For example, splitting I'm not saying no one will ever need these distinctions, but the classes should be along the lines of things people commonly want distinguished programmatically. I think a good way of determining what these cases are is to wait for people to ask to distinguish them, rather than speculate beforehand, adding complexity to the protocol in the process (albeit a small amount). Given that compilation errors are going to mostly be encountered during initial coding of the app, not as much during running it, I don't think they warrant this level of granularity. |
I think we're getting into the weeds a little bit. To sum up what I think briefly:
(Also, from the perspective of personal experience, I have never once used a system and thought to myself "I wish there weren't so many exception subclasses". Never once. I just use the superclass if I don't care. On the other hand, not having exception granularity when you need it is extraordinarily frustrating.) |
Fair enough, I don't think it's important enough to warrant arguing it to death, so I won't. I suspect we just have different thresholds for when it is best to add an exception class. In my experience, most people don't end up using any of the fine grained exception types and it's wasted effort creating these ontologies. |
Marking as settled with the following modification from the original proposal:
|
I'm going to start working on this a bit. |
The fix is up in CR 3248 with @larkost . |
Merged into |
After our recent reorganizing of the error classes we have some places where the drivers are over-using
ReqlDriverError
. The primary abuser is the JavaScript driver, but Python and Ruby also have some instances.I think that all of these should be
ReqlCompileError
s. The older reasoning was that these were driver-generated errors, rather than passed along from the server. That is not really an important attribute to users, so I think it is better to group them based on how a user need to react to them.JavaScript:
Expected X argument (not including options) but found Y.
, seetest/rql_test/src/arity.yaml
Anonymous function returned
undefined. Did you forget a
return?
seetest/rql_test/src/aggregation.yaml
Object keys must be strings.
seetest/rql_test/src/datum/object.yaml
Object field 'a' may not be undefined
seetest/rql_test/src/datum/object.yaml
Second argument to
r.exprmust be a number or undefined.
seetest/rql_test/src/datum/object.yaml
Maximum expression depth exceeded (you can override this with
r.expr(X, MAX_DEPTH)).
seetest/rql_test/src/regression/1133.yaml
Python:
Object keys must be strings.
seetest/rql_test/src/datum/object.yaml
Second argument to
r.exprmust be a number.
seetest/rql_test/src/datum/object.yaml
Calling '>=' on result of infix bitwise operator:
seetest/rql_test/src/math_logic/logic.yaml
Nesting depth limit exceeded
seetest/rql_test/src/regression/1133.yaml
(this should also have a period a the end of the statement for consistency)Ruby:
Object keys must be strings.
seetest/rql_test/src/datum/object.yaml
Second argument to
r.exprmust be a number.
seetest/rql_test/src/datum/object.yaml
Calling '>=' on result of infix bitwise operator:
seetest/rql_test/src/math_logic/logic.yaml
Nesting depth limit exceeded
seetest/rql_test/src/regression/1133.yaml
(this should also have a period a the end of the statement for consistency)Additionally, once this is cleaned out a number of tests in
connections
will need to have their errors re-done and there will be some work there.The text was updated successfully, but these errors were encountered: