-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
fix: ParseError message handling #1619
base: alpha
Are you sure you want to change the base?
Conversation
Thanks for opening this pull request!
|
I would say that this is actually an unwanted error message style. The problem is that it's not clear whether this error message is from Parse Server, the Parse JS SDK or MongoDB. People may then search for "Parse Server error 292" and not find an answer for the issue, or worse references to a completely unrelated Parse Server error 292. Whereas "MongoDB error 292" would likely yield a better search result. It's also unclear for the developer what the Maybe the better solution is to properly write an error message and package the dependency error into it, like:
If the MongoDB errors vary in structure, then we may not be able to that; but we should at least add the error source, like:
Maybe we can also get rid of the quotes and format it more nicely, with util.inspect(). |
I think I get your point @mtrezza |
Codecov ReportBase: 99.89% // Head: 99.89% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## alpha #1619 +/- ##
=======================================
Coverage 99.89% 99.89%
=======================================
Files 61 61
Lines 5973 5984 +11
Branches 1367 1373 +6
=======================================
+ Hits 5967 5978 +11
Misses 6 6
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going back, I think we should never throw an object directly without context. These edge cases should not even make it through a PR review, because looking at the spec, I would say that new Error(message)
expects a string, not an object. From that I would say that ParseError(message)
also expects message
to be a string.
If we want to include the original error object for reference, we can use the options of the Error
object, see this:
throw new Error("New error message", { cause: err });
It seems the issue is not that ParseError
doesn't handle non-string values. The issue is that the code throws non-string values, which seems to be incorrect from a type perspective. I would say this PR doesn't need any of these object to string conversions. It should just fix how the error in thrown originally.
Yeah, I agree but we don't control third-party code running on our servers. while I'm ok removing the edge case it doesn't resolve the issue. if it happens to Parse catch some error wrongly thrown, the server will still log
what do you mean? |
not at all, we just want a nice and readable error message. I personally think my approach by stringifying objects could be useful for those scenarios where we don't control what is coming externally. developers are humans and make mistakes, and unfortunately for JS engines |
Hey @stewones @mtrezza, I also have this problem, I agree the PR seems to be solving the problem directly but what is the best way to solve this @mtrezza? cause we do have an [object, object] going on. Should we add a |
Where is the code that throws the error and creates a new ParseError object? |
@mtrezza did you see my screenshot above? it starts from the RESTController, I'm not an expert in Parse codebase (yet :D) but I don't think it's something worth it to go deep into every place where ParseError is consumed just to verify if an object or string is being passed. why not treat this for general purpose like I'm doing here? at least accept the fact that we can't always expect a string in ParseError (i.e. MongoDB is throwing a |
how do I know this? because if I simply put a I just expanded it to a broader situation where the edge cases mentioned in the beginning may happen. I'm a Parse user for years and started to contribute only recently, but this ParseError: [object Object] thing is smth that always disgusted me so much. we need to fix this asap! also, it will be "required" at some point for the allowDiskUse option I'm going to PR, cause users will get the [object Object] if they don't set a sort specification (as shown in the ^ screenshot) happy to remove those edge cases if you don't like it and let only just lmk |
I get your point, we should get rid of these We could take some inspiration from the In fact, the type of Parse-SDK-JS/src/ParseError.js Line 18 in 5c14029
If we had typescript already rolled out, then it would show a type mismatch error in Parse Server where an object is passed, not in here the Parse JS SDK. I get that just stringifying I think it would help to understand this better if we would first find the code in Parse Server that throws the MongoDB error. |
New Pull Request Checklist
Issue Description
The problem is that log is unclear when some random error happens in the server, eg: MongoDB query has exceeded memory limit
Approach
My proposal is just to make sure the error message is a string otherwise, stringify it.
So this would be the returned log for the example above
Please note that it's strictly necessary making sure those logs are readable, especially when relying on monitoring services like GCP Error Reporting, New Relic, Data Dog, etc...