Abort solidus:install on migration/seed rake failures - #6553
Open
wakqasahmed wants to merge 1 commit into
Open
Conversation
The install generator's rake calls for installing migrations, creating the database, running migrations, installing Active Storage, seeding data, and loading sample data did not pass abort_on_failure, so Thor's default abort_on_failure fallback to the generator's exit_on_failure? was bypassed (execute_command always sets the key explicitly, even to nil). Any failure in these steps was silently swallowed and the generator went on to print 'Solidus has been installed successfully.' Pass abort_on_failure: true explicitly to each of these rake calls so a real failure aborts the generator instead of being ignored.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6035
Problem
solidus:installruns several rake tasks (railties:install:migrations,db:create,db:migrate,active_storage:install,db:seed,spree_sample:load) via the generator'srakehelper without passingabort_on_failure: true.Even though
Solidus::InstallGenerator.exit_on_failure?returnstrue, Thor'srunonly falls back to that class-level default when the:abort_on_failurekey is absent from the options hash (config.fetch(:abort_on_failure, self.class.exit_on_failure?)). Rails'execute_commandalways includes the key explicitly (asnilwhen not set), so the fallback never kicks in and a failing rake task is silently ignored. The generator then proceeds through the rest of its steps and printsSolidus has been installed successfully. Enjoy!even though migrations or seeding actually failed - exactly what was reported in #6035 (adb:migratefailure due to a pre-existing table went unnoticed, seeding then failed too, and the install was reported as successful).Fix
Pass
abort_on_failure: trueexplicitly on each of these rake calls incore/lib/generators/solidus/install/install_generator.rb, so a real failure aborts the generator (a cleanThor::Error, sinceexit_on_failure?is alreadytrue) instead of continuing silently.Test plan
core/spec/lib/generators/solidus/install/install_generator_spec.rbassertingabort_on_failure: trueis passed for the migrations, database creation, active storage, seed, and sample-data rake calls, and that a raised failure fromdb:migratepropagates out ofrun_migrationsinstead of being swallowed.Rails::Generators::Actions#rake/#execute_commandand Thor'sActions#runsource to confirm the exact fallback behavior described above.