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

Managed - Log errors instead of throwing exceptions unless in debug mode #26891

Merged
merged 4 commits into from
Jul 24, 2023

Conversation

colemanw
Copy link
Member

Overview

Alternative to #26849, this aims to minimize hard crashes and appropriately log errors when reconciling managed entities.

Before

When reconciling managed entities, the system would throw an uncaught exception (hard crash) if it encountered an api error.

After

  • Exceptions are caught and logged during normal conditions.
  • During upgrade mode, no error is logged (it may be temporary).
  • In debug mode, the exception is thrown (hard crash) to alert developers of the problem (this is the current status-quo).

Comments

@totten per our discussion

@civibot
Copy link

civibot bot commented Jul 21, 2023

Thank you for contributing to CiviCRM! ❤️ We will need to test and review the PR. 👷

Introduction for new contributors
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers

@civibot civibot bot added the 5.64 label Jul 21, 2023
totten added 2 commits July 21, 2023 01:17
…ditions)

1. The priority is 'error' (or something more severe)
2. The site has enabled debug output
3. The page-request message occurs while the session is available
@totten
Copy link
Member

totten commented Jul 21, 2023

Pushed up a couple changes:

  1. Add more details to log
  2. To ensure that the systemic behavior under error-conditions are the same (with or without debug-mode), just log it.
  3. Bump up the visibility of logged errors (provided by debug-output is enabled).

For an example, I hacked an erroneous mgd into an innocent extension and opened civicrm/menu/rebuild. Here's how it looks:

Screen Shot 2023-07-21 at 1 45 28 AM

I tried simulating a few different failures (e.g. typo in API name; e.g. letting the API fire, but throwing an exception in the middle) -- and it seemed to log reasonably in the ones I tried.

@totten
Copy link
Member

totten commented Jul 24, 2023

@colemanw Oooh, so one of the tests. was specifically expecting it to throw exceptions. But since the typical behavior will be to log it, perhaps we can check the log for the assertion(dfe755c)?

@colemanw
Copy link
Member Author

@totten that worked!

@colemanw colemanw merged commit 8ef07a1 into civicrm:5.64 Jul 24, 2023
@colemanw colemanw deleted the missingEntity2 branch July 24, 2023 02:32
@larssandergreen
Copy link
Contributor

Looks like this doesn't solve the problem in #26674. Build is still failing there for the same reason: API (SearchDisplay, save) does not exist (or the extension it belongs to is not enabled).

I'm guessing maybe upgrade mode is not in effect when we are installing rather than upgrading?

@colemanw
Copy link
Member Author

Oof, guess not. I wonder if there is an equivalent method of checking if we are in install mode.

@colemanw
Copy link
Member Author

@larssandergreen it looks like we could use if (defined('CIVI_SETUP'))

colemanw added a commit to colemanw/civicrm-core that referenced this pull request Jul 27, 2023
Followup from civicrm#26891
to exclude install as well as upgrade mode.
colemanw added a commit to colemanw/civicrm-core that referenced this pull request Jul 27, 2023
Followup from civicrm#26891
to exclude install as well as upgrade mode.
larssandergreen pushed a commit to larssandergreen/civicrm-core that referenced this pull request Jul 27, 2023
Followup from civicrm#26891
to exclude install as well as upgrade mode.
larssandergreen pushed a commit to larssandergreen/civicrm-core that referenced this pull request Jul 27, 2023
Followup from civicrm#26891
to exclude install as well as upgrade mode.
aydun pushed a commit to aydun/civicrm-core that referenced this pull request Jul 31, 2023
Followup from civicrm#26891
to exclude install as well as upgrade mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants