Page MenuHomePhorge

Log Herald rules with invalid keys via phlog()
ClosedPublic

Authored by aklapper on Jul 19 2024, 13:29.
Tags
None
Referenced Files
F2688476: D25735.1734723647.diff
Thu, Dec 19, 19:40
F2682898: D25735.1734675412.diff
Thu, Dec 19, 06:16
F2681566: D25735.1734645508.diff
Wed, Dec 18, 21:58
F2681493: D25735.1734643281.diff
Wed, Dec 18, 21:21
F2681452: D25735.1734642280.diff
Wed, Dec 18, 21:04
Tokens
"Yellow Medal" token, awarded by valerio.bozzolan.

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 1441
Build 1441: 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 ↗(On Diff #2251)

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.