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

Unhelpful assert if serializer leaves 'id' field as an integer #7086

Closed
Benjy1979 opened this issue Mar 6, 2020 · 4 comments · Fixed by #8345
Closed

Unhelpful assert if serializer leaves 'id' field as an integer #7086

Benjy1979 opened this issue Mar 6, 2020 · 4 comments · Fixed by #8345
Labels
🏷️ feat This PR introduces a new feature

Comments

@Benjy1979
Copy link
Contributor

Thank you for opening this issue!

Hopefully, this issue template will help you provide us with enough information to assist in resolving the issue.

Reproduction

Description

If your JSONAPI serializer in a createRecord normalizeResponse hook does not convert the ID field in the JSON from the server into a string instead of an integer, you get something like the following assert:
index.js:172 Uncaught Error: Assertion Failed: Cannot update the id for 'plan:c028ff07-57b3-4281-98b0-ef285c16d3c7' from '5' to '5'.

It doesn't make sense and is quite unhelpful because there is only one call to createRecord so it gives the impression that the adapter is trying to change it twice and ember data is coughing over it.

I would expect it to either auto-convert it or spit out something like:"ID is not of the expected type"

Versions

3.16 Ember data and EMber

Run the following command and paste the output below: yarn list ember-source && yarn list ember-cli && yarn list --pattern ember-data.

C:\inetpub\wwwroot\ember-roomviewer-bighomeshop>yarn list ember-source && yarn list ember-cli && yarn list --pattern ember-data
'yarn' is not recognized as an internal or external command,
operable program or batch file.
@Benjy1979 Benjy1979 changed the title Unhelpful assert if serializer leaves 'id' field to integer Unhelpful assert if serializer leaves 'id' field as an integer Mar 6, 2020
@runspired
Copy link
Contributor

@Benjy1979 could you PR a test for this?

@Benjy1979
Copy link
Contributor Author

erm....ok I will attempt my first ever test

@Benjy1979
Copy link
Contributor Author

Benjy1979 commented Mar 25, 2020

Are there any docs anywhere on how to "PR a test"? I'm not sure what a test is, is it a separate project with some test functions in it? Where do I put it when it's done?

The unhelpful message is coming out from ember.data and into the console so I'm not sure how to go about testing something like that.

@runspired
Copy link
Contributor

@Benjy1979 the folders within packages/ are normal Ember addons/apps. Tests are located in packages/-ember-data/tests/. There are a lot of examples there to look at. If you need any more guidance let me know :)

@runspired runspired moved this to Fix | TODO in EmberData Feb 18, 2022
Repository owner moved this from Fix | TODO to RFC | Needs Implemented in EmberData Dec 8, 2022
@runspired runspired added 🏷️ feat This PR introduces a new feature and removed Improvement labels Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ feat This PR introduces a new feature
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants