Using ED 2.9
The scenario is:
This happens here: https://github.com/emberjs/data/blob/master/addon/-private/system/model/errors.js#L338 the internal reject doesn't get a target so the result of getting 'attribute' from each item is undefined..
This happens for me while using ember-changeset, which uses setProperties on the model with the new changes when there are errors present on the model from a previous save attempt.

Stack:
Error: Assertion Failed: Cannot call get with 'attribute' on an undefined object.
at EmberError (http://localhost:5000/assets/vendor.js:29613:21)
at eval (eval at evaluate (:117:21), <anonymous>:1:9)
at assert (http://localhost:5000/assets/vendor.js:17311:7)
at Object.assert (http://localhost:5000/assets/vendor.js:29425:34)
at Object.get (http://localhost:5000/assets/vendor.js:33936:22)
at exactValue (http://localhost:5000/assets/vendor.js:45477:40)
at http://localhost:5000/assets/vendor.js:45447:26
at http://localhost:5000/assets/vendor.js:45416:22
at Class.forEach (http://localhost:5000/assets/vendor.js:45308:18)
at Class.filter (http://localhost:5000/assets/vendor.js:45415:12)"

I believe I am hitting a similar error, Assertion Failed: Cannot call get with 'attribute' on an undefined object. I was able to trigger my error by trying to save a model in a state that would be rejected by the backend server and then attempting to save it again in an invalid state. Fortunately, I own the code in question, so I was able to use set rather than setProperties as a workaround.
@bryanhickerson think you could make a reproduction in Twiddle (I would, but busy with a new baby boy)?
@knownasilya Sure I can give it a shot.
@knownasilya I'm trying to use ember-cli-mirage to cause a validation error and trigger this issue, but I only get the expected error that the commit was rejected: https://ember-twiddle.com/069df8002805c7479f7924d2e170f8a0?openFiles=routes.index.js%2C Is there a better way to simulate the backend errors?
I also saw this today with ED 2.10. I have not been able to reproduce this yet.
Hitting the same issue.
I could fix it by rolling back the attributes after the Ember Data save rejected:
export default Ember.Component.extend({
...
actions: {
save(changeset) {
let employee = this.get('employee');
changeset.validate().then(() => {
if (changeset.get('isValid')) {
changeset.save().then(() => {
if (this.get('on-success')) {
this.get('on-success')(employee);
}
}, () => {
let errors = employee.get('errors');
errors.forEach((error) => {
changeset.pushErrors(error.attribute, error.message);
});
employee.rollbackAttributes();
});
}
});
}
}
}
This has the added benefit that Ember Changeset execute will already apply properties to the model that fail on server validation and resets these properties (in my case the invalid properties were already shown in another place in the app).
A year later with ED 2.16.3 I am still seeing this in my app. I simply use ED and trying to model.setProperties({<someProps>}) after validation errors and it fails with Assertion Failed: Cannot call get with 'attribute' on an undefined object.
It seems that as workaround using simply model.set('propName', value) instead of model.setProperties() avoid the crash.
Thanks @raido for the failing ember twiddle! This helped a ton tracking down the issue.
Better late than never right, almost a year later :)
Most helpful comment
Thanks @raido for the failing ember twiddle! This helped a ton tracking down the issue.