Repository navigation
feat(events): throttle error emails per fingerprint and globally (#4694) - #4721
Merged
Merged
Conversation
Add the three approved settings with their approved ranges and defaults (all defaults unlimited, so unconfigured apps behave exactly as before): errorEmailRateLimit 0..1000 default 0 errorEmailRateWindowMinutes 1..1440 default 15 errorEmailGlobalRateLimit 0..10000 default 0 The send path reserves a slot after the recipient check and before building the email. A fingerprint is a SHA-256 of root-cause type + message (first 1000 chars) + the first application frame's basename and line, so framework frames are skipped and engine tagContext differences fall back safely. The per-node application-scope state is bounded to 512 fingerprints, uses a fixed window under a named lock, fails open if the lock is unavailable, and keeps suppressed counts until the next allowed email carries a numbers-only summary paragraph. Settings are surfaced in the info page, the CLI defaults inventory, and as a commented example in the generated app's settings files. Consumer AI docs are updated in both the shipped tier and the wheels-new template, with a changelog fragment. Specs drive the recording mail stub: defaults inert, per-fingerprint cap, global cap, window reset, summary counts, fingerprint isolation, no-recipient behaviour, invalid-setting fallbacks, mail-failure safety and the rendered error path. Signed-off-by: Peter Amiri <peter@alurium.com>
… window Two review deviations from the approved brief (#4694): - The fail-open lock path logged a warning on every failure, which moves the flood the feature prevents into the log. Warn once per application via application.wheels["$errorEmailThrottleLockWarned"], mirroring $legacyDebugIpBlockWarned; fail-open behaviour is unchanged. - errorEmailRateWindowMinutes was parsed with the allow-zero helper, so 0 was accepted and then silently clamped to 15. The approved range is 1..1440, so the window now uses a range-aware whole-number helper: 0 is out of range and falls back to 15 with one warning. The ".0" tail allowance is unchanged and now documented as mirroring JobTickEndpoint.$wholeSetting() (D3). Specs cover the once-only lock warning, the range helper, and the reserve path warning for a 0-minute window; both new specs fail against the previous behaviour. Signed-off-by: Peter Amiri <peter@alurium.com>
bpamiri
force-pushed
the
feat/error-email-throttle
branch
from
December 1, 2026 09:22
32aa5d8 to
4d6b439
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #4694 Part 1 from the approved brief (
.ai/wheels/design/error-email-throttling.md, #4719): opt-in error-email throttling with all defaults unlimited, so an unconfigured app's email behaviour is unchanged.errorEmailRateLimit(per fingerprint, per window)errorEmailRateWindowMinutes(fixed window)errorEmailGlobalRateLimit(all error emails, per window)Behaviour
$errorEmailThrottleReserve()returns{allowed=true, summary=""}before computing a fingerprint or touching state. The spec sends five emails with the defaults and asserts five calls and no throttle state key created; it fails if an unconfigured app's email count changes.rootCause.type|rootCause.message (first 1000 chars)|first application frame basename:line, lowercased, SHA-256. Framework frames undervendor/wheelsare skipped; no app frame → first frame; no frames →no-frame.tagContextmay be absent, a struct, a Lucee-style{file,line}or an Adobe-style{template,line}— all handled defensively and covered by specs.application.wheels.errorEmailThrottlestruct (created lazily under the lock), fixed window, per-fingerprint + global counters. Bounded to 512 fingerprints (expired unsuppressed entries pruned, then oldestwindowStartevicted). Only hashes and counters are stored.wheels.errorEmailThrottle.<applicationName>, 5s timeout. If the lock cannot be acquired the email is sent unthrottled and one warning is logged — a throttling failure never loses an error. Per-node/approximate semantics are documented (no shared store; multi-server caps are per node).N occurrence(s) of this error and M error email(s) were suppressed in the last W minute(s).). No exception text; no separate summary email.JobTickEndpoint.$wholeSetting()precedent;0valid for caps, window falls back to 15 when 0/invalid/fractional/scientific/signed/array/struct or out of range), one warning per setting. No on/off switch — opt-in is via the caps, as approved.$mailstill consumes the reservation by design.Settings inventory and docs
vendor/wheels/events/init/debugging.cfm— defaults next tosendEmailOnError.vendor/wheels/public/views/info.cfm— Error Handling inventory.cli/src/commands/wheels/get/settings.cfc— CLI defaults inventory.cli/lucli/templates/app/config/settings.cfmand.../production/settings.cfm.docs/consumer-ai/.ai/views.mdandcli/lucli/templates/app/.ai/views.md(shipped tier);tools/build/scripts/ship-consumer-docs.sh check→consumer-docs check OK.changelog.d/4694-error-email-throttling.added.md.Tests
vendor/wheels/tests/specs/events/ErrorEmailThrottleSpec.cfc(recordingOnErrorEventDouble.$mail(), no SMTP): defaults inert, per-fingerprint cap, different fingerprint still sends, global cap, window reset + summary, global-only summary, fingerprint isolation and frame skipping, defensive tagContext shapes, no-recipient no-state, invalid-setting fallbacks, mail-failure safety, and the rendered error path.Verification
tools/test-matrix.sh lucee7,adobe2023,adobe2025 sqlite→ Lucee 7 pass, adobe2023 pass; adobe2025 u06 was verified separately on a clean engine home: full core suite 7,416 pass / 0 fail / 0 error (the matrix's localadobe2025container had inherited a stale u14 engine volume, which is a local-environment issue, not this change).cfml-complexity.py vendor/wheels --gate 30→ PASS (the fingerprint helper was split into root-details/frame/fingerprint to stay under 30).Unverified / notes
CI status on
299c25a5fAll checks pass except
box install -> serve (CommandBox), which fails before any Wheels request with a CommandBox-environment error, not this diff:This is base-image drift in
ghcr.io/wheels-dev/mirror/ortussolutions/commandbox:latest(the bundledcommandbox-cfconfigdoes not know the Lucee 8 provider); this PR touches no CommandBox/CFConfig/image file, and the workflow's previous run in this repo's history (Oct 16) passed with the older image. Rerunning the job reproduces the identical provider error.The four required contexts still pass:
Lucee 7 + SQLite (LuCLI),Validate Commit Messages,RustCFML (Linux),Consumer AI docs in sync. Also green: cold-start (adobe2023/adobe2025/boxlang/lucee7), smoke testing/production Adobe 2023 and Lucee 7,adobe2023 + sqlite,boxlang + sqlite,lucee7 + h2, complexity gate, CLI suite, Deploy CLI tests + verb smoke, Tutorial E2E.Review round 2 (head
32aa5d824)D1 — the lock-failure warning now logs once per application.
$warnErrorEmailThrottleLockFailure()setsapplication.wheels["$errorEmailThrottleLockWarned"]and returns early on later failures, mirroring$legacyDebugIpBlockWarnedinsettings.cfm; fail-open behaviour is unchanged (the email is still sent unthrottled). A missing lock on every error no longer writes a line per error.D2 — a 0-minute window is out of range, not silently clamped. Added
$errorEmailWholeSetting(name, fallback, maximum, minimum); the caps keep the allow-zero wrapper, anderrorEmailRateWindowMinutesis parsed withminimum=1.0/ fractional / signed / scientific / out-of-range now falls back to 15 with one warning via the same one-warning-per-setting path; the silent clamp is gone.D3 — named, no behaviour change. The
^[0-9]+(\.0+)?$regex still accepts a.0tail; this mirrors theJobTickEndpoint.$wholeSetting()precedent, whose comment documents the same engine-double allowance. The new helper's docblock says so explicitly so it is not re-litigated.Mutation proof (specs bite against the old behaviour, then restored green):
13 passed, 1 failed — "warns once, not per failure, when the throttle lock is unavailable: Expected [false] to be true".13 passed, 1 failed — "rejects a 0-minute window with a warning instead of silently clamping it: the reserve path must warn for a 0-minute window".qa's verified properties are untouched: the inert-defaults guard (5 sends → 5 mails, no throttle state), per-fingerprint cap, global cap across unique fingerprints, summary counts, fail-open no-throw, fingerprint isolation and the rest of the 11 original specs are unchanged and still pass.
CI on
32aa5d824: every check passes exceptbox install -> serve (CommandBox), which is the pre-existing #4722 drift being fixed separately in #4723 (verified green there: runs 46603184614 / 46603242450). Nothing else is red.Rebase onto develop
af3a9a3c9(head4d6b43938)Rebased onto current develop so this branch picks up the #4723 CommandBox smoke fix (
af3a9a3c9); no code changes beyond the rebase, and the diff for the D1/D2 files is empty against the previous head (git diff 32aa5d824 4d6b43938 -- vendor/wheels/events/EventMethods.cfc vendor/wheels/tests/specs/events/ErrorEmailThrottleSpec.cfc= no output).box install -> serve (CommandBox)is now GREEN on the rebased head: job run — the ci(commandbox): pin the smoke image and engine, add dispatch (#4722) #4723 digest/engine pins make it pass for real, with all its assertions executing.$warnErrorEmailThrottleLockFailure()+application.wheels["$errorEmailThrottleLockWarned"](one-time warning, fail-open unchanged).errorEmailRateWindowMinutesparsed withminimum = 1; the0-minute range spec and the once-lock-warning spec are unchanged.4d6b43938: 26 total, 0 failing (the LuCLI leg's first run hit the known Maven Central 429 flake on the sqlite-jdbc download;gh run rerun --failedpassed).