data icon indicating copy to clipboard operation
data copied to clipboard

[BUGFIX] uncommitted model should be able to 'becameValid'

Open yratanov opened this issue 2 years ago • 4 comments

Hey guys,

I faced a problem and did a test + added a fix, the simplest way to replicate:

myModel = this.store.createRecord('my-model');
myModel.errors.add('fieldA', ['blank']);
myModel.errors.add('fieldB', ['blank']);
later(() => {
  set(myModel, 'fieldA', 'value');
  set(myModel, 'fieldB', 'value');
}, 1000);

It raises an error:

Attempted to handle event `becameValid` on <my-model:null> while in state root.loaded.created.uncommitted.

I'm not sure why it is being raised only if there are 2 or more fields with errors.

yratanov avatar Jun 17 '22 13:06 yratanov

once the defunct state-machine is dropped this would be a non-issue. Probably the more interesting test to add is what happens to the user-observable state during this transition. You might also want to try completing the work in #7971

runspired avatar Jul 15 '22 21:07 runspired

I'm experiencing this issue going from 3.24 to 3.28. @runspired Would it be possible for this to be released as a patch in 3.28?

deanmarano avatar Jul 19 '22 19:07 deanmarano

I think it should be added as a fix for both v3.28 and v4. Even if this code will be dropped completely, at least it will allow users to upgrade. Also, it's a regression.

yratanov avatar Jul 20 '22 04:07 yratanov

@yratanov I don't think it's a regression, it's simply a state that has never been handled by ember-data. More than likely it should have been handled a long time ago, but never got implemented. If folks are encountering this upgrading from 3.24->3.28 that is especially surprising. It suggests that pre-request-manager activation failed creates were ignored in terms of internal state and would not have added validation errors to individual attributes, which itself would be a bug.

runspired avatar Jul 22 '22 06:07 runspired

closed in favour of #8154

yratanov avatar Aug 26 '22 09:08 yratanov