I was going to run something along the lines of `drush mi my_migration || echo "FAILURE!"`... or have my CI test for the exit code to find when there were failures importing... instead... I'm getting an exit code of 0 even withs something like this:

Processed 4953 items (4270 created, 2 updated, 23 failed, 658 ignored) - done with 'upgrade_d7_taxonomy_term'

I would expect that if you have any "failed" you would have an exit code > 0... particularly when my migration is throwing error output like the following

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null: INSERT INTO {taxonomy_term_field_data}  [error]
(tid, vid, langcode, name, description__value, description__format, weight, changed, default_langcode) VALUES
(:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3,
:db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7,
:db_insert_placeholder_8); Array
(
    [:db_insert_placeholder_0] => 8426
    [:db_insert_placeholder_1] => person_title
    [:db_insert_placeholder_2] => en
    [:db_insert_placeholder_3] =>
    [:db_insert_placeholder_4] =>
    [:db_insert_placeholder_5] =>
    [:db_insert_placeholder_6] => 10
    [:db_insert_placeholder_7] => 1463413778
    [:db_insert_placeholder_8] => 1
)
CommentFileSizeAuthor
#4 exit-code.diff656 bytesmoshe weitzman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

generalredneck created an issue. See original summary.

moshe weitzman’s picture

The fix will be for this command to call drush_set_error whenever a migration fails. I think that the '23' fails in the example constitutes a failure. Its fine if the command keeps running, but logging the error will cause the right exit code to be emitted in the end.

mikeryan’s picture

Version: 8.x-2.0-beta1 » 8.x-4.x-dev
Priority: Minor » Normal

More than minor, I think.

moshe weitzman’s picture

Assigned: Unassigned » moshe weitzman
Status: Active » Needs review
FileSize
656 bytes

Pretty easy fix

  • moshe weitzman committed 0206504 on 8.x-4.x
    Issue #2726707 by moshe weitzman: drush mi almost always returns 0 as an...

  • moshe weitzman committed 0df4bfd on 8.x-3.x
    Issue #2726707 by moshe weitzman: drush mi almost always returns 0 as an...
moshe weitzman’s picture

Status: Needs review » Fixed

Merged into 4.x and 3.x. I'm happy to back this out if anyone objects.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.