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

Uncaught TypeError: Cannot read property 'map' of undefined #3071

Closed
ChrisHonniball opened this issue May 15, 2015 · 13 comments · Fixed by #3126
Closed

Uncaught TypeError: Cannot read property 'map' of undefined #3071

ChrisHonniball opened this issue May 15, 2015 · 13 comments · Fixed by #3126

Comments

@ChrisHonniball
Copy link

Receiving: Uncaught TypeError: Cannot read property 'map' of undefined | embedded-records-mixin.js:485 on beta.17 with Ember 1.12.0.

This prevents the model.save() request from being sent to the server.

@ChrisHonniball
Copy link
Author

Here is my serializer:

export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
  attrs: {
    addresses: { embedded: 'always' },
    phones: { embedded: 'always' },
    emails: { embedded: 'always' },
    notes: { embedded: 'always' },
    reminders: { embedded: 'always' },
    calls: { embedded: 'always' },
    customFields: { embedded: 'always' }
  }
});

@igorT
Copy link
Member

igorT commented May 15, 2015

Which line causes it? Can you maybe reproduce your error in a JSBin? There is a sample one in the CONTRIBUTING.md

@jakesjews
Copy link
Contributor

This JSBin should replicate the issue. http://jsbin.com/cehelabiqe/4/edit
It looks like the error happens when the response from saving a record with an embedded array doesn't include the array. It doesn't seem to throw the error when using beta-16 in the same situation.

@jkatsnelson
Copy link

I think I ran into the same situation, but the error came out like this for me:

https://www.dropbox.com/s/f1qbpy85o3mfw70/Screenshot%202015-05-15%2020.13.09.png?dl=0

@jkatsnelson
Copy link

reverting back to beta-16 works like a charm.

@ChrisHonniball
Copy link
Author

I'll make a JSBin as soon as I get a chance but mine doesn't even get to the API when I get this error. I'm assuming it's happening for me at serialization.

@ChrisHonniball
Copy link
Author

Reverting to beta-16.1 flags a lot of deprecation warnings for your DS.attr calls when using Ember 1.12.0.

@jakesjews
Copy link
Contributor

I was wrong in my previous comment. it looks like it's happening before it sends anything to the server on the save. It could be happening when it tries to serialize a null embedded array.

@igorT
Copy link
Member

igorT commented May 16, 2015

You really should normalize your embedded payloads and pass back a [] for an empty array, but I do agree we should probably guard here.
cc @wecc

@jakesjews
Copy link
Contributor

I agree. We just had some cases where it was unnoticed and it was kinda hard to find the issue. Maybe an assert would be helpful?

@igorT
Copy link
Member

igorT commented May 31, 2015

Ping @wecc

@ChrisHonniball
Copy link
Author

This seems to have returned in 2.0.1.

@mgharbik
Copy link

mgharbik commented Oct 1, 2015

I am running into the same error when trying to override the serializeBelongsTo. Use Ember 2.0.1 as @ChrisHonniball

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

Successfully merging a pull request may close this issue.

5 participants