- Issue created by @omkar.podey
- @omkarpodey opened merge request.
- š®š³India omkar.podey
I changed the code to catch
\Throwable
instead of\Exception
(\Throwable covers both php errors and exceptions)- First, I think we don't our code execution to stop abruptly on an error and allow it to cleanup (like destroying the stage) and catching
\Throwable
allows us to do that. - Another reason i cloud think of is if we catch the errors too then we can probably format and display them better which might make it easier to debug.
- First, I think we don't our code execution to stop abruptly on an error and allow it to cleanup (like destroying the stage) and catching
- Assigned to phenaproxima
- Status changed to Needs review
almost 2 years ago 10:17am 13 February 2023 - š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
- š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
Also, isn't this basically proposing to do a superset of š Unhandled Composer Stager exceptions leave the update process in an indeterminate state Fixed ?
- šŗšøUnited States phenaproxima Massachusetts
First, I think we don't want our code execution to stop abruptly on an error and allow it to cleanup (like destroying the stage and other things) and catching errors using \Throwable allows us to do that.
This is what I'm thinking. I don't see any reason, generally, for us to treat errors and exceptions any differently in Package Manager and AU. (If there is such a case, it should be one-off and heavily commented.) To me, being resilient means we should catch and handle as many problems as we can, and that means catching \Throwable.
- Issue was unassigned.
- Status changed to Needs work
almost 2 years ago 1:58pm 15 February 2023 - š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
- š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
Since this affects reliability, tagging
core-mvp
. - Assigned to omkar.podey
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 9:55am 21 February 2023 - š®š³India omkar.podey
I don't see any more instances to be changed, setting to needs review
- Assigned to omkar.podey
- Status changed to Needs work
over 1 year ago 11:41am 21 February 2023 - š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
The MR is still targeting
8.x-2.x
š We need a new MR, that targets3.0.x
. - @omkarpodey opened merge request.
- š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
@omkar.podey: please also add
diff /var/www/html/core/scripts/dev/commit-code-check.sh modules/contrib/automatic_updates/commit-code-check.sh
like I suggested during the call ā that's going to make comparing this simpler.Also:
ls -al /var/www/html/core
andls -al modules/contrib/automatic_updates
.All just prior to executing
modules/contrib/automatic_updates/commit-code-check.sh --drupalci
. - š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
This is an absolute nightmare to figure out. This approach is also a nightmare to debug. Enough. The alternative approach I've started at #3343430-8: [PP-1] Commit our copied and edited version of commit-code-check.sh ā looks promising.
For this issue: just reverting all code quality checks temporarily, so @omkar.podey can continue š
- Assigned to wim leers
- Status changed to Needs review
over 1 year ago 1:49pm 22 February 2023 - Issue was unassigned.
- Status changed to RTBC
over 1 year ago 7:51am 23 February 2023 - Status changed to Needs review
over 1 year ago 2:05pm 23 February 2023 - šŗšøUnited States phenaproxima Massachusetts
Question.
Do we have any other places where we are directly re-throwing a caught exception? Something like:
try { // Do an exceptional thing } catch (\Throwable $e) { // Do stuff... throw $e; }
...because, in those cases, we are also losing the backtrace of $e, and should be wrapping those exceptions too in most cases.
- Status changed to RTBC
over 1 year ago 2:28pm 23 February 2023 - š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
Ideally we'd have test coverage of this. It wouldn't be too hard to add, but I'm not sure it would be worth it at this point.
This.
The point is that it's not knowable what might fail, but that we have a big net, catch it, and surface it in an appropriate way. That is already the case here! š
Do we have any other places where we are directly re-throwing a caught exception? Something like:
I specifically checked that. See #9.
(Method used: search for
throw new
in all*.php
files in bothsrc
andpackage_manager/src
.) - Status changed to Needs review
over 1 year ago 2:39pm 23 February 2023 - šŗšøUnited States phenaproxima Massachusetts
(Method used: search for throw new in all *.php files in both src and package_manager/src.)
š¤ Well...
throw new
would not be the thing. It'd be more likethrow $
(i.e., throwing some already-caught exception).And
grep -irn 'throw \$' .
does find some stuff:./package_manager/tests/modules/package_manager_test_validation/src/EventSubscriber/TestSubscriber.php:136: throw $results; ./package_manager/tests/modules/package_manager_bypass/src/LoggingCommitter.php:49: throw $exception; ./package_manager/tests/src/Kernel/ComposerExecutableValidatorTest.php:300: throw $output; ./package_manager/tests/src/Kernel/FixtureManipulatorTest.php:390: throw $exception; ./package_manager/src/ComposerInspector.php:106: throw $e; ./package_manager/src/Stage.php:540: throw $error; ./automatic_updates_extensions/src/BatchProcessor.php:67: throw $error; ./src/Validator/VersionPolicyValidator.php:198: throw $unknown_target; ./src/Validator/VersionPolicyValidator.php:211: throw $unknown_target; ./src/BatchProcessor.php:77: throw $error;
Most of these seem fine. The only one that's maybe a little questionable is the one in ComposerInspector; we're re-throwing an exception from Composer Stager. IMHO that one should be wrapped. Thoughts?
- Status changed to RTBC
over 1 year ago 2:52pm 23 February 2023 - š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
Oh!
Interesting. But that's not the pattern this issue was aiming to address, that's why I didn't check for that.
No, the one in
ComposerInspector
is 100% intentional. (That happened in š Validate compliance with composer minimum stability during PreRequireEvent Fixed after very careful deliberation.)We are not in the business of wrapping
composer-stager
's exceptions inComposerInspector
because validators ought to handle exceptions ofcomposer-stager
themselves.Otherwise,
\Drupal\package_manager\Validator\ComposerSettingsValidator::validate()
wouldn't have to do this for example:try { $setting = (int) $this->inspector->getConfig('secure-http', $dir); } catch (\Exception $exception) { $event->addErrorFromThrowable($exception, $this->t('Unable to determine Composer <code>secure-http
setting.'));
return;
}
If you're arguing that
ComposerInspector
should wrap all\PhpTuf\ComposerStager\Domain\Service\ProcessRunner\ComposerRunnerInterface::run()
exceptions, that'd be a different concern/discussion, and IMHO out of scope. -
phenaproxima ā
committed 059443b7 on 3.0.x authored by
omkar.podey ā
Issue #3341224 by omkar.podey, Wim Leers, phenaproxima: Always catch \...
-
phenaproxima ā
committed 059443b7 on 3.0.x authored by
omkar.podey ā
- Status changed to Fixed
over 1 year ago 2:57pm 23 February 2023 - šŗšøUnited States phenaproxima Massachusetts
You've convinced me. Merged!
Automatically closed - issue fixed for 2 weeks with no activity.