fix(fix): PG::DatetimeFieldOverflow in Notifications::WorkflowJob#switch_state (WP #65108)#23425
Draft
thykel wants to merge 1 commit into
Draft
fix(fix): PG::DatetimeFieldOverflow in Notifications::WorkflowJob#switch_state (WP #65108)#23425thykel wants to merge 1 commit into
thykel wants to merge 1 commit into
Conversation
…_state (WP #65108)
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.
What are you trying to accomplish?
Administrators could enter an arbitrarily large value in the "User actions aggregated within" field under Administration → Emails and notifications → Aggregation. When a value large enough to overflow PostgreSQL's
timestamprange was stored (e.g.9999999999), every subsequent call toNotifications::WorkflowJobcrashed with:This blocked notification delivery for all users on the affected instance.
What approach did you choose and why?
The fix is applied at three layers to be robust against both future bad input and existing bad values already in the database:
UI constraint (
AggregationSettingsForm): Addedmax: 3600(andmin: 0) to the number input so the browser enforces the allowed range before a form submission is even made.Server-side contract validation (
Settings::UpdateContract): Added ajournal_aggregation_time_minutes_rangevalidation that rejects any value outside0..3600. This is the authoritative guard — it runs regardless of how the setting is written (UI, API, console).Runtime cap in the job (
Notifications::WorkflowJob): Thewait:lambda now uses[Setting.journal_aggregation_time_minutes.to_i, 3600].min.minutes. This prevents the crash for instances that already have an out-of-range value stored in the database, where the contract fix alone would not help.The cap of 3600 minutes (1 hour) matches the value explicitly suggested in the bug report and is far below the PostgreSQL timestamp ceiling.
Merge checklist