Page MenuHomePhorge

Log Herald rules with invalid keys via phlog()
ClosedPublic

Authored by aklapper on Jul 19 2024, 13:29.

Details

Summary

When Herald rules fail unexpectedly due to relying on a (now) invalid key, allow Phorge administrators to get aware by creating an entry in the error log via phlog() instead of crossing fingers that someone may from time to time get the idea to open and read Herald transcripts.

Refs T15885

Test Plan

See steps in T15885; check error log.

Diff Detail

Repository
rP Phorge
Branch
heraldRuleInvalid
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 1444
Build 1444: arc lint + arc unit

Event Timeline

Note that every unmanaged exception is logged. So if you don't see a log, something is already managing this.

Better to see who is calling getConditionsForField() that has probably a try-catch that should have a phlog() but hasn't

In short, requireFieldImplementation seems correct in their legacy version, and something is not ideal in the consumer, that has a try catch. That try-catch should be edited.

Marking as "probably something different should be done"

This revision now requires changes to proceed.Jul 19 2024, 13:49

Per Valerio's previous comments

Hmm I guess now my patch title is too narrow as it logs any Herald exceptions? :D

Seems super nice. Minor comment. If we do this, the stack trace is NOT shared:

phlog(pht('An exception occurred executing a Herald rule: "%s" Review '.
  'the Herald transcripts and correct or disable the problematic rule.',
  $ex->getMessage()));

If we do this instead (or something similar), the stack trace is shared:

phlog(pht('An exception occurred executing a Herald rule. Review '.
  'the Herald transcripts and correct or disable the problematic rule.'),
  $ex);

Untested. Still, thanks, seems lovely

I personally don't see value in sharing a stacktrace in this case. YMMV :)

This revision is now accepted and ready to land.Jul 20 2024, 08:22
src/applications/herald/engine/HeraldEngine.php
539

You are right from the other diff, here it would be probably better $caught, not $ex

  • Use $caught, not $ex.
  • Include Herald rule monogram in log message for easier finding.