A webhook's retention_days is now stored exactly as entered, and 0 means its events are kept forever.
001_schema.sql drops DEFAULT 30 on retention_days, and Webhook.RetentionDays drops its default:30 tag. Without them a 0 is stored as 0, so RetentionForeverDays (the 365000-day stand-in for forever) and the Webhook.BeforeSave hook that wrote it are gone.
retainsForever no longer knows a stand-in value; it reads 0 as forever. The reaper, the webhook page's event counts and the "forever" label all go through it.
parseRetentionDays accepts 0 or 1 to MaxFiniteRetentionDays and refuses anything else with the existing messages. A blank field still gives 30 on the new webhook form and keeps the stored value on the edit form, so the two handlers needed no change.
The edit form now pre-fills 0 for a webhook that keeps its events, which matches what its help text already said.
The README Webhook section is rewritten to match.
Tests cover blank, 0, a day count and a too-large value on the new webhook form, 0 surviving create and save, and the reaper keeping the events of a webhook set to 0.
Judgement call: retainsForever reads a negative value as forever too, not only 0. The forms refuse a negative value, but read as a day count it would put the reaper's cutoff in the future and delete every event, so it is read as forever, as it was before.
Model: opus-5-5
Closes https://git.eeqj.de/sneak/webhooker/issues/539.
A webhook's `retention_days` is now stored exactly as entered, and `0` means its events are kept forever.
- `001_schema.sql` drops `DEFAULT 30` on `retention_days`, and `Webhook.RetentionDays` drops its `default:30` tag. Without them a `0` is stored as `0`, so `RetentionForeverDays` (the 365000-day stand-in for forever) and the `Webhook.BeforeSave` hook that wrote it are gone.
- `retainsForever` no longer knows a stand-in value; it reads `0` as forever. The reaper, the webhook page's event counts and the "forever" label all go through it.
- `parseRetentionDays` accepts `0` or `1` to `MaxFiniteRetentionDays` and refuses anything else with the existing messages. A blank field still gives 30 on the new webhook form and keeps the stored value on the edit form, so the two handlers needed no change.
- The edit form now pre-fills `0` for a webhook that keeps its events, which matches what its help text already said.
- The README Webhook section is rewritten to match.
Tests cover blank, `0`, a day count and a too-large value on the new webhook form, `0` surviving create and save, and the reaper keeping the events of a webhook set to `0`.
Judgement call: `retainsForever` reads a negative value as forever too, not only `0`. The forms refuse a negative value, but read as a day count it would put the reaper's cutoff in the future and delete every event, so it is read as forever, as it was before.
Model: opus-5-5
clawbot
self-assigned this 2026-10-15 13:36:11 +02:00
internal/handlers/source_management_test.go, the comment above TestHandleSourceCreate_PrefillsDefaultFromConstant (lines 286 to 288): it says the test keeps the new webhook form's pre-filled retention from becoming "a third hardcoded copy of the 30-day policy". The two copies it counted were DefaultRetentionDays and the default:30 tag that this change removes, so DefaultRetentionDays is now the only one and the sentence no longer matches the code. Acceptable: the comment says what the test guards now, that the pre-filled value comes from database.DefaultRetentionDays rather than a hardcoded 30.
Judgement call: reading a negative stored value as forever is accepted, because read as a day count it would delete every event the webhook has.
Judgement call: leaving retention_days nullable is accepted; it matches the rest of the schema, every save writes a value, and a null reads as 0.
Model: opus-5-5
FAIL (needs-rework)
1. `internal/handlers/source_management_test.go`, the comment above `TestHandleSourceCreate_PrefillsDefaultFromConstant` (lines 286 to 288): it says the test keeps the new webhook form's pre-filled retention from becoming "a third hardcoded copy of the 30-day policy". The two copies it counted were `DefaultRetentionDays` and the `default:30` tag that this change removes, so `DefaultRetentionDays` is now the only one and the sentence no longer matches the code. Acceptable: the comment says what the test guards now, that the pre-filled value comes from `database.DefaultRetentionDays` rather than a hardcoded 30.
Judgement call: reading a negative stored value as forever is accepted, because read as a day count it would delete every event the webhook has.
Judgement call: leaving `retention_days` nullable is accepted; it matches the rest of the schema, every save writes a value, and a null reads as 0.
Model: opus-5-5
retention_days loses its column default of 30, and Webhook.RetentionDays
its default tag, so a 0 is stored as 0. The 365000-day stand-in
RetentionForeverDays and the BeforeSave hook that wrote it are gone. The
reaper and the "forever" label read 0 as forever, and the forms accept 0
or 1 to MaxFiniteRetentionDays; a blank field still gives 30 on the new
webhook form and keeps the stored value on the edit form. A negative
value, which the forms refuse, is still read as forever so it cannot put
the reaper's cutoff in the future.
Model: opus-5-5
The comment above TestHandleSourceCreate_PrefillsDefaultFromConstant now says the test checks that the new webhook form pre-fills its retention from database.DefaultRetentionDays rather than a hardcoded 30; no other comment or README sentence still counted the removed column default or the old 365000-day value.
Model: opus-5-5
The comment above `TestHandleSourceCreate_PrefillsDefaultFromConstant` now says the test checks that the new webhook form pre-fills its retention from `database.DefaultRetentionDays` rather than a hardcoded 30; no other comment or README sentence still counted the removed column default or the old 365000-day value.
Model: opus-5-5
PASS: a retention of 0 is now stored, kept by retention and shown as forever on every page and form; a blank field on the new webhook form gives 30; a value above database.MaxFiniteRetentionDays is refused with the existing message; and nothing of the old 365000-day value, the save hook or the column default remains, so #539 is done.
Model: opus-5-5
PASS: a retention of `0` is now stored, kept by retention and shown as forever on every page and form; a blank field on the new webhook form gives 30; a value above `database.MaxFiniteRetentionDays` is refused with the existing message; and nothing of the old 365000-day value, the save hook or the column default remains, so https://git.eeqj.de/sneak/webhooker/issues/539 is done.
Model: opus-5-5
clawbot
merged commit f10440b7cc into next2026-10-15 20:03:33 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #539.
A webhook's
retention_daysis now stored exactly as entered, and0means its events are kept forever.001_schema.sqldropsDEFAULT 30onretention_days, andWebhook.RetentionDaysdrops itsdefault:30tag. Without them a0is stored as0, soRetentionForeverDays(the 365000-day stand-in for forever) and theWebhook.BeforeSavehook that wrote it are gone.retainsForeverno longer knows a stand-in value; it reads0as forever. The reaper, the webhook page's event counts and the "forever" label all go through it.parseRetentionDaysaccepts0or1toMaxFiniteRetentionDaysand refuses anything else with the existing messages. A blank field still gives 30 on the new webhook form and keeps the stored value on the edit form, so the two handlers needed no change.0for a webhook that keeps its events, which matches what its help text already said.Tests cover blank,
0, a day count and a too-large value on the new webhook form,0surviving create and save, and the reaper keeping the events of a webhook set to0.Judgement call:
retainsForeverreads a negative value as forever too, not only0. The forms refuse a negative value, but read as a day count it would put the reaper's cutoff in the future and delete every event, so it is read as forever, as it was before.Model: opus-5-5
FAIL (needs-rework)
internal/handlers/source_management_test.go, the comment aboveTestHandleSourceCreate_PrefillsDefaultFromConstant(lines 286 to 288): it says the test keeps the new webhook form's pre-filled retention from becoming "a third hardcoded copy of the 30-day policy". The two copies it counted wereDefaultRetentionDaysand thedefault:30tag that this change removes, soDefaultRetentionDaysis now the only one and the sentence no longer matches the code. Acceptable: the comment says what the test guards now, that the pre-filled value comes fromdatabase.DefaultRetentionDaysrather than a hardcoded 30.Judgement call: reading a negative stored value as forever is accepted, because read as a day count it would delete every event the webhook has.
Judgement call: leaving
retention_daysnullable is accepted; it matches the rest of the schema, every save writes a value, and a null reads as 0.Model: opus-5-5
7c273d2d19toec4679cd17The comment above
TestHandleSourceCreate_PrefillsDefaultFromConstantnow says the test checks that the new webhook form pre-fills its retention fromdatabase.DefaultRetentionDaysrather than a hardcoded 30; no other comment or README sentence still counted the removed column default or the old 365000-day value.Model: opus-5-5
PASS: a retention of
0is now stored, kept by retention and shown as forever on every page and form; a blank field on the new webhook form gives 30; a value abovedatabase.MaxFiniteRetentionDaysis refused with the existing message; and nothing of the old 365000-day value, the save hook or the column default remains, so #539 is done.Model: opus-5-5