Closed gholias closed 6 years ago
Could you please provide me a sample repo to re-produce the issue? SEE: https://github.com/strongloop/loopback/wiki/Reporting-issues#bug-report
I'm having EXACLTY the same error. If I use a not valid email (like bondgmailcom) it says a differente message "must provide a valid email""
If i use the base class , User, it works like a charm
{
"name": "AccountUser",
"base": "User",
"idInjection": true,
"options": {
"validateUpsert": true
},
"mysql": {
"schema": "prod",
"table": "account_user"
},
"properties": {},
"validations": [],
"relations": {},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
],
"methods": {}
}
module.exports = function(AccountUser) {
};
AccountUser
.create({
email: emailregistro.value,
password: senharegistro.value
})
.$promise.then(function(resp) {
console.log(resp);
alert(resp);
}, function errorCallback(response) {
alert(response.data.error.message);
});
Tested using supervisor or node directly... my versions are node v4.2.2,
strongloop v5.0.1 (node v4.2.2)
├── strong-arc@1.8.4 (b7b568d)
├── strong-build@2.0.6 (d008a3e)
├── strong-deploy@3.1.2 (be6180a)
├── strong-mesh-models@8.1.0 (62e539b)
├── strong-pm@5.0.1 (b96f806)
├── strong-registry@1.1.5 (f46e58f)
├── strong-start@1.3.2 (1327018)
├─┬ strong-supervisor@3.3.1 (1e39220)
│ └── strong-agent@2.0.2 (4ea7ee9)
├── generator-loopback@1.13.0 (a884c0b)
├── node-inspector@0.7.4
└── nodefly-register@0.3.3
I found out that the record save was failing for another reason, but the message said the email was invalid. In my case was a problem related to a wrong Oracle field type.
Check the details of the error object, something like this:
if (err.details) {
console.log("unknownServerError details: " + util.inspect(err.details.codes));
}
Thanks a lot!!!
You are right.. it shows me a error in mysql... in my case was a column mapped that doesnt exists in database .. some default fields used in User that does not exists in my AccountUser table (in my case was realm column)
Anyway, would be better to have a different error message here rather than "email invalid", do u agree?
yes, I agree The error message make lost a lot of time trying to see what could be wrong with the values I was saving.
On Wed, Nov 25, 2015 at 11:20 AM, Mario Mol notifications@github.com wrote:
Thanks a lot!!!
You are right.. it shows me a error in mysql... in my case was a column mapped that doesnt exists in database .. the weird here is that this account-user.json was generated by sontrongloop discover...
Anyway, would be better to have a different error message here rather than "email invalid", do u agree?
— Reply to this email directly or view it on GitHub https://github.com/strongloop/loopback/issues/1803#issuecomment-159605218 .
Felipe Oliveira, Software Developer
Thanks for bringing this to our attention!
I'll label this issue as enhancement
/feature
to show better error messages.
Thanks
It's a year later and I still get the same issue. It says email not valid, but the actual error digging down is that the table has not been created.
What is the status on those better error messages?
This is a bug.. not sure why it was marked as a feature.
Just hit the same error and glad I found this thread. In my case, I attempted to simply create a second user with the same email. I used the stock POST /users
with { email, password }
as form data
Here's the full log:
3|APP | Unhandled error for request POST /api/v1/users: ValidationError: The `user` instance is not valid. Details: `email` is invalid (value: "simo@xxxx.com"
).
3|APP | at /usr/src/app/node_modules/loopback-datasource-juggler/lib/dao.js:323:12
3|APP | at ModelConstructor.<anonymous> (/usr/src/app/node_modules/loopback-datasource-juggler/lib/validations.js:513:13)
3|APP | at ModelConstructor.next (/usr/src/app/node_modules/loopback-datasource-juggler/lib/hooks.js:83:12)
3|APP | at done (/usr/src/app/node_modules/loopback-datasource-juggler/lib/validations.js:510:25)
3|APP | at /usr/src/app/node_modules/loopback-datasource-juggler/lib/validations.js:588:7
3|APP | at ModelConstructor.<anonymous> (/usr/src/app/node_modules/loopback-datasource-juggler/lib/validations.js:382:5)
3|APP | at DestroyableTransform.allCb (/usr/src/app/node_modules/loopback-datasource-juggler/lib/dao.js:2016:7)
3|APP | at emitOne (events.js:96:13)
3|APP | at DestroyableTransform.emit (events.js:188:7)
3|APP | at /usr/src/app/node_modules/google-cloud/node_modules/through2/through2.js:19:12
3|APP | at _combinedTickCallback (internal/process/next_tick.js:67:7)
3|APP | at process._tickDomainCallback (internal/process/next_tick.js:122:9)
As @gholias mentioned, the real error is buried in the details error of the ValidationError object.
{
name: 'ValidationError',
message: 'The `user` instance is not valid. Details: `email` is invalid (value: "simo@xxxx.com").',
statusCode: 422,
details: {
context: 'user',
codes: { email: [ 'uniqueness.Error: Connect Failed' ] }, <<<<<<<< Real Error
messages: Errors { email: [ 'is invalid' ] }
}
}
When an email address on a subclass of User is not unique, I'm getting an error message about another column not existing: UNIQUENESS.ERROR: COLUMN "HEIGHTINCHES" DOES NOT EXIST
This was happening because migration was failing somewhere else with a new required property on a column that had null values (you can allow nulls via the custom connector properties if needed btw).
@gholias @timlind @ritch
After I redefined the email
property in my custom user.json
as follows the error message improved:
"email": {
"type": "string",
"index": {"unique": true}
},
The new error is now much better:
{
"error": {
"statusCode": 422,
"name": "ValidationError",
"message": "The `user` instance is not valid. Details: `email` Email already exists (value: \"simo@****.com\").",
"details": {
"context": "user",
"codes": {
"email": [
"uniqueness"
]
},
"messages": {
"email": [
"Email already exists"
]
}
}
}
}
I hope this helps!
the same error
Getting this as well
Need to investigate to see the real cause of the issue (Connection Failed? Juggler? etc?) as it seems like an incorrect error message is being thrown OR is it actually a validation issue before it can be fixed.
I have resolve this issue. assign null to all unnecessary fields of User model in your model. example:
"credentials":null,
"challenges":null,
"realm":null,
"status": null,
"created": null,
"lastUpdated": null,
I hope this will work.
assign null to unnecessary fields "credentials":null, "challenges":null, "realm":null, "status": null, "created": null, "lastUpdated": null
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This is a bug and unresolved.
I tried withDEBUG=* node .
What I could see is that its actually an SQL error, but for some reason we get an incorrect validation error for email field.
Here is some log from the report:
Excerpt from the SQL error:
code: 'ER_BAD_FIELD_ERROR',
errno: 1054,
sqlMessage: 'Unknown column \'gender\' in \'field list\'',
sqlState: '42S22',
index: 0,
sql: 'SELECT `name`,`email`,`dob`,`gender`,`mobile_no`,`pickup_coordinates`,`destination_coordinates`,`time_range`,`availability`,`days_of_the_week`,`vehicle_type`,`vehicle_name`,`ratings`,`realm`,`username`,`password`,`credentials`,`challenges`,`emailVerified`,`verificationToken`,`status`,`created`,`lastUpdated`,`id` FROM `customer` WHERE `email`=\'example@gmail.com\' ORDER BY `id`' }
This error is clearly about unknown column name 'gender' but instead of that we get the following error:
Unhandled error for request POST /api/customers: ValidationError: The `customer` instance is not valid. Details: `email` is invalid (value: "example@gmail.com").
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS
file at the top-level of this repository.
I a have a class that inherits from the Loopback user class.
I started getting an error this morning after I update to the latest version.
Is there anything Im missing?
This is my CarDrive model definition
I appreciate any help