diff --git a/vendor/wheels/events/EventMethods.cfc b/vendor/wheels/events/EventMethods.cfc index 97582317fb..7967c3e630 100644 --- a/vendor/wheels/events/EventMethods.cfc +++ b/vendor/wheels/events/EventMethods.cfc @@ -242,7 +242,14 @@ component extends="wheels.Global" implements="wheels.interfaces.events.EventHand if (Len(local.normalized)) { local.file = GetFileFromPath(local.normalized); if (!Len(local.file)) { - local.file = local.normalized; + // GetFileFromPath can return "" on Windows for a normalized path + // (e.g. a trailing separator or a drive-relative form). Fall back + // to the last path segment, never the full path: a deployment root + // in the fingerprint would split the same failure across installs. + local.file = ListLast(local.normalized, "/"); + } + if (!Len(local.file)) { + local.file = "no-frame"; } } local.line = local.use.line; @@ -275,15 +282,26 @@ component extends="wheels.Global" implements="wheels.interfaces.events.EventHand return; } application.wheels["$errorEmailThrottleLockWarned"] = true; - WriteLog( - file = "wheels", - type = "warning", + $errorEmailThrottleLogWarning( text = "Wheels: the error-email throttle lock was not available; sending error emails unthrottled (fail-open). This warning is logged once per application start." ); } catch (any e) { } } + /** + * Internal seam for the lock warning: the spec replaces this method with a + * counter, so the "one warning per application, not one per error" contract + * is actually observed rather than inferred from the flag. Production writes + * one wheels.log warning; the try/catch keeps logging failures harmless. + */ + public void function $errorEmailThrottleLogWarning(required string text) { + try { + WriteLog(file = "wheels", type = "warning", text = arguments.text); + } catch (any e) { + } + } + /** * Internal: decides whether this error email may be sent and, when one is * allowed after suppressions, returns the numbers-only summary paragraph. diff --git a/vendor/wheels/tests/specs/events/ErrorEmailThrottleSpec.cfc b/vendor/wheels/tests/specs/events/ErrorEmailThrottleSpec.cfc index 3ebfc21f64..707a7c7bd9 100644 --- a/vendor/wheels/tests/specs/events/ErrorEmailThrottleSpec.cfc +++ b/vendor/wheels/tests/specs/events/ErrorEmailThrottleSpec.cfc @@ -254,12 +254,20 @@ component extends="wheels.WheelsTest" { it("warns once, not per failure, when the throttle lock is unavailable", () => { var em = mailer(); + // Count the warnings, not just the flag: a regression that keeps the + // flag set but drops the early return would log per failure and must + // fail here. The seam is $errorEmailThrottleLogWarning. + prepareMock(em); + em.$("$errorEmailThrottleLogWarning"); expect(StructKeyExists(application.wheels, "$errorEmailThrottleLockWarned")).toBeFalse(); em.$warnErrorEmailThrottleLockFailure(); - expect(StructKeyExists(application.wheels, "$errorEmailThrottleLockWarned")).toBeTrue(); - // The second call must take the early return (one warning total). em.$warnErrorEmailThrottleLockFailure(); - expect(application.wheels.$errorEmailThrottleLockWarned).toBeTrue(); + em.$warnErrorEmailThrottleLockFailure(); + expect(em.$count("$errorEmailThrottleLogWarning")).toBe( + 1, + "the lock warning must be written once per application, not once per failure" + ); + expect(StructKeyExists(application.wheels, "$errorEmailThrottleLockWarned")).toBeTrue(); }); });