deluan / contentful-migrate

🐎 Schema migration tooling for Contentful, with state management
https://www.contentful.com/blog/2018/09/13/content-model-changes-scale-telus-cms-as-code/
MIT License
60 stars 37 forks source link

Validation errors not returning exit code 1 #20

Closed sheakelly closed 6 years ago

sheakelly commented 6 years ago

I am getting an error but the exit code is 0 which mean the build passes incorrectly. I was using an invalid character in the contentType name which I fixed it but I think when any error occurs it should fail the build i.e. exit 1

Migration unsuccessful: 
Batch failed

Error: {"status":"Unprocessable Entity","message":"Validation error","details":{"errors":[{"name":"regexp","details":"Does not match /^[a-zA-Z][a-zA-Z0-9_]*$/","value":"inline-link-group","pattern":"^[a-zA-Z][a-zA-Z0-9_]*$","path":["fields",3,"id"]}]},"url":"https://api.contentful.com:443/spaces/qwerty/environments/dev/content_types/topic"}

Error: {"status":"Conflict","message":"","details":{},"url":"https://api.contentful.com:443/spaces/qwerty/environments/dev/content_types/topic/published"}

Please check the errors log for more details: /app/errors-1534393589930.log
  error : Error: Batch failed

🚨  Error applying migrations in dev! See above for error message
deluan commented 6 years ago

Hey, thanks for the report. I tested it here but I cannot reproduce the issue. How are you calling the ctf-migrate command? Here is what I get when running an invalid migration:

$ ctf-migrate -s qqxhciuzx3io -e master list -c headline
Listing headline
  [2018-06-13 15:06:12] 20180613190106-create-headline.js : Create content model for Headline
  [pending]             20180821151031-test-delete-invalid-field.js : Test issue 20
$ echo $?
0
$ ctf-migrate -s qqxhciuzx3io -e master up -c headline
Processing headline
  up : 20180821151031-test-delete-invalid-field.js
Validation failed

Errors in /Users/deluan/TW/test/migrations/headline/20180821151031-test-delete-invalid-field.js

Line 6: Field with id "invalidField" cannot be deleted because it does not exist.
 4:   const flowConfiguration = migration.editContentType('headline');
 5:
 6:   flowConfiguration.deleteField('invalidField');
 7: };
 8:

🚨  Migration unsuccessful
$ echo $?
1
deluan commented 6 years ago

Forget about my last comment, reading more carefully your message, I was able to reproduce the error (using an invalid contentTypeId), and pushed a fix for it. Fixed in version 0.6.1

sheakelly commented 6 years ago

Awesome thank you :)