Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions vendor/wheels/events/EventMethods.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 11 additions & 3 deletions vendor/wheels/tests/specs/events/ErrorEmailThrottleSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

});
Expand Down
Loading