Open psbanka opened 4 years ago
@psbanka 👋 I merged a PR that included improvements to an existing test to more closely match your case. However, I'm still seeing the tests pass. Do you happen to know how your situation might not be reflected in the tests?
Feel free to reopen the issue if you feel the need to!
I'm running into this as well. Is there a way to work around this?
Some data I've gathered:
changeset.save()
is called{"errors":{"user_email":["digit@example.com is already a client"]}}
source
reveals something like this:{ userEmail: null, firstName: null, lastName: null, email: null }
because typeof null === 'object'
buildPathToValue
is called with null
as the source
EXPLODE
I'm running into this too and thank the gods I'm not alone in this, because I've been scratching my head for hours on this one and have not figured out a workaround yet.
@snewcomer Might want to reopen this one
@jherdman For 6), if possible === null
, then the first part of that if expression would fail and we would move on.
Do you happen to know of a good test we could add?
@jherdman For 6), if
possible === null
, then the first part of that if expression would fail and we would move on.Merge-deep in
ember-changeset
and merge-deep invalidated-changeset
are slightly different, where that expression will fail appropriately in ember-changeset, but not in validated-changeset astypeof(null) == 'object'
https://github.com/poteto/ember-changeset/blob/master/addon/utils/merge-deep.js#L75
Yesterday when stepping through my code (which is using ember-changeset 3.10.1), I was hitting that spot in validated-changeset
where it blows up like @jherdman described, when possible
is null
https://github.com/validated-changeset/validated-changeset/blob/master/src/utils/merge-deep.ts#L71
Going up a level and starting at the mergeDeep
call, it succeeds in the case of merging plain objects, but merging an object with null values { userEmail: null, firstName: null, lastName: null, email: null }
and a changeset is where things get hinky.
Published 3.10.2. Hopefully this resolves the merge-deep
issues!
Works for me! Thanks @snewcomer
Version
3.9.2
Test Case
Sorry, don't have a test case for this
Steps to reproduce
When saving a changeset, have a server respond with a 406 error response and the following body:
Expected Behavior
I expect the Ember Data exception to be passed to my
catch()
rather than a type-error from ember-changesetActual Behavior
ember-changeset throws a
TypeError
:TypeError: Cannot convert undefined or null to object
, and it is impossible to get the original error back from Ember Data. Instead, I have to pull all the information out of thechangeset.snapshot().changes
object, save them to the model manually, and save the model in order to get the Ember Data exception.