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

Calling findRecord without an id results in confusing error state in production builds #5958

Closed
paddyobrien opened this issue Apr 1, 2019 · 3 comments

Comments

@paddyobrien
Copy link

Calling store.findRecord('foo', undefined) fails in a dev build with a very helpful error message:

Error: Assertion Failed: `id` passed to `findRecord()` has to be non-empty string or number

However doing the same thing in a production build does not fail and instead issues a request as if you had called store.findAll('foo'). It then resolves the promise with a model in a weird state where all fields are undefined:

Screenshot 2019-04-01 at 17 22 14

This probably happens because the argument validation is implemented using Ember.assert here and these assertions are stripped from production builds.

This behaviour can result in an extremely confusing and hard to understand situation where a model hook resolves but the model is in a completely broken state. It would be preferable in these cases for the model hook to just fail with the same or similar exception as we see in dev.

@snewcomer
Copy link
Contributor

I find the debug scenario helpful but in client code overall, if I am unsure of the type of identifier will be passed, I assumed this would be left up to the client to guard. What are your thoughts?

@travisghansen
Copy link

All things considered, the divergent behavior here is extremely bad form IMO.

@paddyobrien
Copy link
Author

Looks like this got fixed in #6561

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

3 participants