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

Renaming a content type causes Strapi to crash #2482

Closed
tonyberetini opened this issue Dec 13, 2018 · 5 comments
Closed

Renaming a content type causes Strapi to crash #2482

tonyberetini opened this issue Dec 13, 2018 · 5 comments
Assignees
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around status: can not reproduce Not enough information to reproduce

Comments

@tonyberetini
Copy link

Node.js version: 11.4.0
NPM version: 6.4.1
Strapi version: 3.0.0-alpha.16
Database: MySQL 5.7
Operating system: Ubuntu 18.04

What is the current behavior?
Created content type was originally called Approval which was renamed to Status.

Steps to reproduce the problem

  1. Create a content type under content type builder called "Approval"
  2. Add a new field called Status
  3. Add a couple of content values like Approved, Pending, Published under the new content type
  4. Go back to content type builder and rename content type from "approval" to "status"
  5. Strapi crashes and it wont restart.

What is the expected behavior?
Expected behavior is for Strapi to rename all the relevant fields in the database and not crash

Suggested solutions
If there is no way to fix this for now implement validation or disable field editing to avoid this from happening for now.

@lauriejim lauriejim self-assigned this Dec 14, 2018
@lauriejim lauriejim added issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around status: can not reproduce Not enough information to reproduce labels Dec 14, 2018
@lauriejim
Copy link
Contributor

Hello! I'm not able to reproduce your issue.

Did you have an error log in your terminal ?

@connectwithub
Copy link

connectwithub commented Dec 18, 2018

Having a similar issue. In my case, what i debugged through it was that :

  1. Renaming created another field rather than updating previous field name.
  2. As the field was required, when a new column was added for the same no info was added to the new field, neither the previous column info nor the default value provided. This led to the error
    at Query.Sequence._packetToError (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Query.ErrorPacket (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/mysql/lib/protocol/sequences/Query.js:77:18)
    at Protocol._parsePacket (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/mysql/lib/protocol/Protocol.js:278:23)
    at Parser.write (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/mysql/lib/protocol/Parser.js:76:12)
    at Protocol.write (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/mysql/lib/Connection.js:91:28)
    at Socket.<anonymous> (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/mysql/lib/Connection.js:502:10)
    at Socket.emit (events.js:182:13)
    at Socket.EventEmitter.emit (domain.js:441:20)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
    at Protocol._enqueue (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Connection.query (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/mysql/lib/Connection.js:200:25)
    at /media/udbhav/WoRk/testing/strapi/test-project/node_modules/knex/lib/dialects/mysql/index.js:144:18
From previous event:
    at Client_MySQL._query (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/knex/lib/dialects/mysql/index.js:135:12)
    at Client_MySQL.query (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/knex/lib/client.js:192:17)
    at Runner.<anonymous> (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/knex/lib/runner.js:138:36)
From previous event:
    at /media/udbhav/WoRk/testing/strapi/test-project/node_modules/knex/lib/runner.js:47:21
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:120:23)
From previous event:
    at Runner.run (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/knex/lib/runner.js:33:30)
    at Raw.Target.then (/media/udbhav/WoRk/testing/strapi/test-project/node_modules/knex/lib/interface.js:23:43)
(node:27329) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27329) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
In my case the Column name was: 'SP'
3. The cloumn for the field before renaming was still present and not removed.

Possible Solutions according to me is instead of adding a new column in MySql try renaming the column.

PS. Same issue also happens for adding a new column after adding some data

@lauriejim
Copy link
Contributor

Hello @connectwithub, I don't understand what you explain.

@connectwithub
Copy link

@lauriejim All I am saying that renaming a field creates another column in Mysql which is created with null values. The previous data is left in the field with the previous name. And if we make that field required or if its required field beforehand then as there ain't any data in the database corresponding to that field this leads to a throwing up of error in the cli that I have mentioned above.

My suggested solution was that if we update the content type name from cli or ui then either the original column be renamed or atleast the data from that column be copied to the new column or the default data be added to the column so that no error is thrown. Being a developer myself I feel that this is possible and if you could point me to right file for this I would be more than happy to open a pull request for this.

@lauriejim
Copy link
Contributor

Ho okay I see!
This issue is about your need #1114

Thank you for your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around status: can not reproduce Not enough information to reproduce
Projects
None yet
Development

No branches or pull requests

3 participants