rahulserver
rahulserver

Reputation: 11225

Undefined in Sails js "Invalid attributes sent to undefined"

On providing wrong attribute values while execution .create() helper in waterline, the err json has the following message:

[Error (E_VALIDATION) 2 attributes are invalid] Invalid attributes sent to undefined: • username • A record with that 'username' already exists ('someusername'). • email • A record with thatemailalready exists ('[email protected]').

The issue is that the "Invalide attribute sent to undefined" should ideally tell the model name instead of undefined. So why is it happening?

A related issue had been opened in github about 2 years ago: https://github.com/balderdashy/waterline/issues/1118

But can't see any responses on that!

Upvotes: 1

Views: 377

Answers (1)

David Wayne Griffith
David Wayne Griffith

Reputation: 29

It would be helpful to include a copy of your model js. However, it would appear that there is validation, specifically unique attribute on the model property being set to true. From what I gather you understand this already. Anyway, as far as the message of undefined is concerned it's a known issue and here you can read up on here: https://github.com/balderdashy/sails/commit/b8c3813281a041c0b24db381b046fecfa81a14b7#commitcomment-18455430

Cheers PS: I get these messages all time when I am inserting data in my user table with the unique constraint that is about to be duplicated.

Upvotes: 1

Related Questions