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

better error handling for missing model error #8328

Merged

Conversation

TC-42-54
Copy link
Contributor

Description of what you did:

Actually, if a model is missing from the configuration but present in the database, you get the following error message:
[2020-10-14T09:17:43.597Z] debug ⛔️ Server wasn't able to start properly. [2020-10-14T09:17:43.599Z] error TypeError: Cannot read property 'attributes' of undefined at Object.getNature (/usr/app/node_modules/strapi-utils/lib/models.js:83:61) at Object.keys.forEach.name (/usr/app/node_modules/strapi-connector-bookshelf/lib/mount-models.js:127:21) at Array.forEach (<anonymous>) at Object.keys.map (/usr/app/node_modules/strapi-connector-bookshelf/lib/mount-models.js:120:40)

The problem is it doesn't let you know which model is causing the error.
I just added an error handling statement to show which model is blocking the server from starting.

@TC-42-54 TC-42-54 requested a review from a team as a code owner October 14, 2020 09:40
Signed-off-by: Thomas Chezieres <tchezieres@MacBook-Pro.lan>
@TC-42-54 TC-42-54 force-pushed the models-missing-collection-error-handling branch from 7717bc4 to 5020233 Compare October 14, 2020 09:45
Signed-off-by: Thomas Chezieres <tchezieres@MacBook-Pro.lan>
@TC-42-54 TC-42-54 force-pushed the models-missing-collection-error-handling branch from 56dee67 to 8304869 Compare October 14, 2020 14:55
@codecov
Copy link

codecov bot commented Oct 14, 2020

Codecov Report

Merging #8328 into master will decrease coverage by 0.00%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8328      +/-   ##
==========================================
- Coverage   33.20%   33.19%   -0.01%     
==========================================
  Files        1220     1220              
  Lines       13610    13612       +2     
  Branches     1355     1356       +1     
==========================================
  Hits         4519     4519              
- Misses       8208     8209       +1     
- Partials      883      884       +1     
Flag Coverage Δ
#front 24.72% <ø> (ø)
#unit 54.46% <93.33%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/strapi-utils/lib/models.js 25.00% <0.00%> (-0.32%) ⬇️
packages/strapi-admin/services/user.js 83.89% <100.00%> (ø)
packages/strapi/lib/commands/admin-reset.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 435b294...2b5b11c. Read the comment docs.

Copy link
Member

@alexandrebodin alexandrebodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thank you for your contribution 💯

@alexandrebodin alexandrebodin added source: core:database Source is core/database package issue: enhancement Issue suggesting an enhancement to an existing feature labels Oct 15, 2020
@alexandrebodin alexandrebodin added this to the 3.2.4 milestone Oct 15, 2020
@alexandrebodin alexandrebodin merged commit 2f97ff1 into strapi:master Oct 15, 2020
@TC-42-54
Copy link
Contributor Author

LGTM, Thank you for your contribution 💯

You're welcome, it's a pleasure to work with Strapi 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: enhancement Issue suggesting an enhancement to an existing feature source: core:database Source is core/database package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants