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

Return exit code on unhandled exceptions, and allow process to go on when upgrading a module fails #752

Merged
merged 5 commits into from
Jul 12, 2024

Conversation

Quetzacoalt91
Copy link
Member

@Quetzacoalt91 Quetzacoalt91 commented Jul 2, 2024

✔️ Waiting for #727 to be merged first

Questions Answers
Description? We found out in some workflow, an exception not handled would still return the error code 0, allowing the next steps to be run. This PR makes sure a non-zero code is returned.
Type? bug fix
BC breaks? Nope
Deprecations? Nope
Fixed ticket? /
Sponsor company @PrestaShopCorp
How to test? CI must be red if an issue is triggered by a module for instance.

PR contents:

  • Returns a non zero code when an exception is not handled
  • Remove html contents (displayed on CLI which is a non-sense)
  • Allow process to continue on error during updates
  • Display error details as warnings

@Quetzacoalt91 Quetzacoalt91 self-assigned this Jul 2, 2024
@Quetzacoalt91
Copy link
Member Author

The workflow UI Tests / UI Tests (1.7.8.11, 8.1.7, major, 7.4) (pull_request) now fails as expected

 INFO - === Step upgradeModules
INFO - 2 modules will be upgraded.
INFO - === Step upgradeModules
CRITICAL - [INTERNAL] /var/www/html/classes/Hook.php line 558 - PrestaShopModuleException: Hook with the name displayHeader has been registered by Ps_checkout, but the corresponding method hookDisplayHeader has not been defined in the Module class.
#0 /var/www/html/classes/module/Module.php(1061): HookCore::registerHook(Object(Ps_checkout), 'displayHeader', NULL)
#1 /var/www/html/modules/ps_checkout/upgrade/upgrade-8.3.3.0.php(41): ModuleCore->registerHook('displayHeader')
#2 /var/www/html/classes/module/Module.php(591): upgrade_module_8_3_3_0(Object(Ps_checkout))
#3 /var/www/html/modules/autoupgrade/classes/UpgradeTools/ModuleAdapter.php(268): ModuleCore->runUpgradeModule()
#4 /var/www/html/modules/autoupgrade/classes/UpgradeTools/ModuleAdapter.php(240): PrestaShop\Module\AutoUpgrade\UpgradeTools\ModuleAdapter->doUpgradeModule('ps_checkout')
#5 /var/www/html/modules/autoupgrade/classes/TaskRunner/Upgrade/UpgradeModules.php(79): PrestaShop\Module\AutoUpgrade\UpgradeTools\ModuleAdapter->upgradeModule(46347, 'ps_checkout', false)
#6 /var/www/html/modules/autoupgrade/classes/TaskRunner/ChainedTasks.php(55): PrestaShop\Module\AutoUpgrade\TaskRunner\Upgrade\UpgradeModules->run()
#7 /var/www/html/modules/autoupgrade/cli-upgrade.php(50): PrestaShop\Module\AutoUpgrade\TaskRunner\ChainedTasks->run()
#8 {main}
CRITICAL - [INTERNAL] /var/www/html/classes/Hook.php line 558 - PrestaShopModuleException: Hook with the name displayHeader has been registered by Ps_checkout, but the corresponding method hookDisplayHeader has not been defined in the Module class.
#0 /var/www/html/classes/module/Module.php(1061): HookCore::registerHook(Object(Ps_checkout), 'displayHeader', NULL)
#1 /var/www/html/modules/ps_checkout/upgrade/upgrade-8.3.3.0.php(41): ModuleCore->registerHook('displayHeader')
#2 /var/www/html/classes/module/Module.php(591): upgrade_module_8_3_3_0(Object(Ps_checkout))
#3 /var/www/html/modules/autoupgrade/classes/UpgradeTools/ModuleAdapter.php(268): ModuleCore->runUpgradeModule()
#4 /var/www/html/modules/autoupgrade/classes/UpgradeTools/ModuleAdapter.php(240): PrestaShop\Module\AutoUpgrade\UpgradeTools\ModuleAdapter->doUpgradeModule('ps_checkout')
#5 /var/www/html/modules/autoupgrade/classes/TaskRunner/Upgrade/UpgradeModules.php(79): PrestaShop\Module\AutoUpgrade\UpgradeTools\ModuleAdapter->upgradeModule(46347, 'ps_checkout', false)
#6 /var/www/html/modules/autoupgrade/classes/TaskRunner/ChainedTasks.php(55): PrestaShop\Module\AutoUpgrade\TaskRunner\Upgrade\UpgradeModules->run()
#7 /var/www/html/modules/autoupgrade/cli-upgrade.php(50): PrestaShop\Module\AutoUpgrade\TaskRunner\ChainedTasks->run()
#8 {main}
Error: Process completed with exit code 64.

@Quetzacoalt91 Quetzacoalt91 changed the title Return exit code on unhandled exception Return exit code on unhandled exceptions, and allow process to go on when upgrading a module fails Jul 3, 2024
@Quetzacoalt91 Quetzacoalt91 marked this pull request as ready for review July 5, 2024 09:08
Hlavtox
Hlavtox previously approved these changes Jul 5, 2024
M0rgan01
M0rgan01 previously approved these changes Jul 8, 2024
@Quetzacoalt91 Quetzacoalt91 added this to the 6.0.0 milestone Jul 9, 2024
AureRita
AureRita previously approved these changes Jul 11, 2024
Copy link
Contributor

@AureRita AureRita left a comment

Choose a reason for hiding this comment

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

Hi @Quetzacoalt91

Thank you for your PR, I tested it and it seems to works as you can see :

image

image

Tested from :
1.7.6.4 to 8.1.7
8.0.5 to 8.1.7
8.1.5 to 8.1.7
8.1.7 to 9.0.0
8.1.5 to 9.0.0
8.0.5 to 9.0.0

Because the PR seems to works as expected, It's QA ✔️

FYI : When you baddly change the "_construct" of a module, you still have an exception as you can see :

image

(seen with @Quetzacoalt91 )

Thank you

@Quetzacoalt91 Quetzacoalt91 dismissed stale reviews from AureRita and M0rgan01 via 8b7fb17 July 11, 2024 13:45
Copy link
Contributor

@ga-devfront ga-devfront left a comment

Choose a reason for hiding this comment

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

image

@nicosomb nicosomb merged commit 8c292a2 into PrestaShop:dev Jul 12, 2024
36 checks passed
@Quetzacoalt91 Quetzacoalt91 deleted the stop-on-exception branch July 12, 2024 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants