Skip to content
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

Error while validating with ember-model-validator #478

Open
jayseo5953 opened this issue Sep 1, 2023 · 0 comments
Open

Error while validating with ember-model-validator #478

jayseo5953 opened this issue Sep 1, 2023 · 0 comments

Comments

@jayseo5953
Copy link

jayseo5953 commented Sep 1, 2023

Hello, I have a model with a fragment from ember-data-model-fragments
And I use ember-model-validator
Before saving I run validate to validate fields.

When I have an error in a field (ex, name) , it throws this uncaught error on the adapter instead of adding the field error (ex "Name is empty") to the model with the fragment even though the error that the validation caught was not the fragment property.

Error: Attempted to handle eventbecameError on <fragments/my-fragment:null> while in state root.loaded.saved.

the stack trace is this

commitWasRejected

commitWasRejected

_fragmentCommitWasRejected

In the first commitWasRejected, updating it from

  const fragment =
        key in this._inFlightFragments
          ? this._inFlightFragments[key]
          : this._fragmentData[key];
      if (fragment == null) {
        continue;
      }
      behavior.commitWasRejected(fragment)

to

  const fragment = this._inFlightFragments[key]
      if (fragment == null) {
        continue;
      }
      behavior.commitWasRejected(fragment)

to remove the tenary operator to strictly use this._inFlightFragments[key] seems to solve the issue but I am not sure if this is safe to do. All I was doing was to revert to this 5.0 version

versions

"ember": 4,4,1,
"ember-data": "~4.4.0",
"ember-model-validator": "3.14.0",
"ember-data-model-fragments": "^6.0.3",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant