# Bug COMMS-356 - PG::DatetimeFieldOverflow in Notifications::WorkflowJob#switch_state

Project: Stream Communicator
Status: closed
URL: https://community.openproject.org/work_packages/COMMS-356

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module | Modules and project features / Email notifications, Modules and project features / Notification center, Modules and project features / Work packages |
| Target versions | 17.6.0 |
| Observed in versions |  |
| Sprint |  |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable | Hagen Mahnke |
| Product manager |  |
| Developers | Tom Hykel |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

**Steps to reproduce**

1.  As an administrator, go to Administration -&gt; Emails and notifications -&gt; Aggregation
    
2.  Insert a very large value into the &quot;User actions aggregated within&quot; field
    
3.  Try to create a work package
    
    <img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/699919/content">
    

**Buggy behaviour**

1.  It is possible to insert a ridiculously large value in the aggregation field
    
2.  An error is thrown on the attempted work package creation. Update is likely to fail as well.
    

**Expected behaviour**

1.  Limit the aggregation period input to sensible values. e.g. 3600
    
2.  The limitation should avoid the error on work package creation
    

<br>

```text
ERROR:  timestamp out of range: "677347521-07-22 12:03:56"
CONTEXT:  unnamed portal parameter $5 = '...'
```

### **Logs**

[https://appsignal.com/openproject-gmbh/sites/673c8d4183eb67dcd6c4e764/exceptions/incidents/96](https://appsignal.com/openproject-gmbh/sites/673c8d4183eb67dcd6c4e764/exceptions/incidents/96)

```text
app/workers/concerns/state_machine_job.rb:73 Notifications::WorkflowJob#switch_state
app/workers/concerns/state_machine_job.rb:43 Notifications::WorkflowJob#perform
app/workers/shared_job_setup.rb:59 block in SharedJobSetup#prepare_job_context
app/workers/shared_job_setup.rb:76 SharedJobSetup#with_clean_request_store
app/workers/shared_job_setup.rb:55 SharedJobSetup#prepare_job_context
vendor/plugins/openproject-multitenancy/app/extenders/workers/delayed_job_extender.rb:14 block in Multitenancy::JobWithSchemaData::ClassMethods#execute
vendor/plugins/openproject-multitenancy/app/extenders/workers/delayed_job_extender.rb:13 Multitenancy::JobWithSchemaData::ClassMethods#execute
```
