-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Parse Server should return consistent error messages #7444
Comments
Agree the key should be consistent. We also have a related issue regarding consistency of the error message itself. Regarding key name, I would suggest
rather than
|
I even agree with you @mtrezza, but the REST documentation doesn't mention the |
Well, mere semantic aesthetics don't justify breaking changes. So if |
The SDK’s actually use constructor(code, message) {
super(message);
this.code = code;
Object.defineProperty(this, 'message', {
enumerable: true,
value: message,
});
} + (NSError *)errorWithCode:(NSInteger)code message:(NSString *)message;
+ (NSError *)errorWithCode:(NSInteger)code message:(NSString *)message shouldLog:(BOOL)shouldLog; /**
* Construct a new ParseException with an external cause.
*
* @param message A message describing the error in more detail.
* @param cause The cause of the error.
*/
public ParseException(int theCode, String message, Throwable cause) {
super(message, cause);
code = theCode;
} public struct ParseError: ParseType, Decodable, Swift.Error {
/// The value representing the error from the Parse Server.
public let code: Code
/// The text representing the error from the Parse Server.
public let message: String
/// An error value representing a custom error from the Parse Server.
public let otherCode: Int?
init(code: Code, message: String) {
self.code = code
self.message = message
self.otherCode = nil
}
|
@cbaker6 on the public API the name of the field is For example, if you go to the REST guide and search for Alternatively you can go straight to the Response Format section in the REST guide, where you will find exactly the information I said. |
This isn't true, the Swift SDK decodes directly from JSON with a strict decoder: public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
do {
code = try values.decode(Code.self, forKey: .code)
otherCode = nil
} catch {
code = .other
otherCode = try values.decode(Int.self, forKey: .code)
}
message = try values.decode(String.self, forKey: .message)
} In addition, you can check the JS SDK ParseError encoding test: it('has a proper json representation', () => {
const error = new ParseError(123, 'some error message');
expect(JSON.parse(JSON.stringify(error))).toEqual({
message: 'some error message',
code: 123,
});
}); console log output from the server: parse_1 | error: Error handling request: ParseError: An appName, publicServerURL, and emailAdapter are required for password reset and email verification functionality.
parse_1 | at UsersRouter._throwOnBadEmailConfig (/parse-server/lib/Routers/UsersRouter.js:315:15)
parse_1 | at UsersRouter.handleVerificationEmailRequest (/parse-server/lib/Routers/UsersRouter.js:356:10)
parse_1 | at /parse-server/lib/Routers/UsersRouter.js:427:19
parse_1 | at /parse-server/lib/PromiseRouter.js:175:7
parse_1 | at Layer.handle [as handle_request] (/parse-server/node_modules/express/lib/router/layer.js:95:5)
parse_1 | at next (/parse-server/node_modules/express/lib/router/route.js:137:13)
parse_1 | at Route.dispatch (/parse-server/node_modules/express/lib/router/route.js:112:3)
parse_1 | at Layer.handle [as handle_request] (/parse-server/node_modules/express/lib/router/layer.js:95:5)
parse_1 | at /parse-server/node_modules/express/lib/router/index.js:281:22
parse_1 | at Function.process_params (/parse-server/node_modules/express/lib/router/index.js:335:12) {
parse_1 | code: 1
parse_1 | } {"error":{"message":"An appName, publicServerURL, and emailAdapter are required for password reset and email verification functionality.","code":1}} |
@cbaker6 see this I didn't search all the Android SDK code, but I quickly found it here: |
This would make it decode based on |
It doesn't test the function in question ( And I can't find a test for the |
@danielsanfr sorry for the mistake. It seems your PR is valid as there is confusion. It seems many of the SDKs decode the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@danielsanfr May I ask what the status of this issue is? |
New Issue Checklist
Issue Description
The Parse Server should return consistent error messages. However, it is returning a
message
field when an internal error occurs, see:parse-server/src/middlewares.js
Lines 375 to 378 in d8dc524
However, if you look at the other returns in:
parse-server/src/middlewares.js
Line 364 in d8dc524
and
parse-server/src/middlewares.js
Line 368 in d8dc524
Steps to reproduce
Sorry, but I don't know how to reproduce it consistently.
Actual Outcome
Expected Outcome
Failing Test Case / Pull Request
Environment
Server
4.5.0
Linux
Both
Database
Both
Any
Both
Client
Anyone
Anyone
Logs
Not applicable
The text was updated successfully, but these errors were encountered: