Carry the event's receipt time into every delivery (closes #257)
All checks were successful
check / check (push) Successful in 3m59s

Every Slack and Mattermost message the engine sent rendered a
`*Timestamp:*` of `0001-01-01T00:00:00Z` while the stored event's
`created_at` was correct. Both delivery paths reconstruct the event
from the Task that carries it, and no Task carries a receipt time, so
`FormatSlackMessage` formatted a zero `time.Time`.

`Task` is not the place to fix it: it is built in three places, two of
them on the receiver side, and a field there would have left the live
first-attempt and retry paths still zero while only the restart
recovery path came out correct. The stored row stays the single source
of truth instead. `resolveEventBody` becomes `hydrateEvent` and reads
`created_at` alongside the body, so every path that reconstructs an
event gets the receipt time with it.

A task that inlined its body previously never read the event row. It
does now, and a read failure there is no longer fatal: the row can be
reaped by retention while a queued delivery still holds its body, and
such a delivery goes out with the timestamp unset rather than being
dropped. A task with no inlined body still fails, as before.
This commit is contained in:
2026-08-24 04:26:02 +00:00
parent b2c9acdaa6
commit 62b9463827
3 changed files with 473 additions and 13 deletions

View File

@@ -151,6 +151,16 @@ func (e *Engine) ExportProcessRetryTask(
e.processRetryTask(ctx, task)
}
// ExportEventForTask exposes the event reconstruction the delivery
// paths run: buildEventFromTask followed by hydrateEvent.
func (e *Engine) ExportEventForTask(
webhookDB *gorm.DB, task *Task,
) (database.Event, error) {
return e.hydrateEvent(
webhookDB, buildEventFromTask(task), task,
)
}
// ExportProcessDelivery exposes processDelivery.
func (e *Engine) ExportProcessDelivery(
ctx context.Context,