Cap sync_interval at 30 days (#174)

sync_interval has no upper bound, so a value above MaxInt32 passes validation and then fails the INTEGER column insert as a 500, and very large values overflow time.Duration.

- add MaxSyncInterval (30 days in seconds)
- reject sync_interval above it with a 400 via ValidateSyncInterval
- cover the boundary in TestValidateSyncInterval and over-limit values in TestSyncIntervalAPI

Reviewed-on: #174
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
This commit was merged in pull request #174.
This commit is contained in:
2026-10-25 20:23:01 +11:00
committed by BenVincent
parent a75aef8ded
commit 5f33abba93
3 changed files with 12 additions and 5 deletions
+3 -1
View File
@@ -57,7 +57,7 @@ func TestMutableTTLOmittedVsZero(t *testing.T) {
}
// sync_interval round-trips through the API and DB on github_* remotes and is
// rejected when negative or on a type without a background syncer.
// rejected when negative, over the maximum, or on a type without a background syncer.
func TestSyncIntervalAPI(t *testing.T) {
if testDSN == "" {
t.Skip("Docker unavailable")
@@ -93,6 +93,8 @@ func TestSyncIntervalAPI(t *testing.T) {
for _, body := range []string{
`{"name":"si-neg",` + gh + `,"sync_interval":-1}`,
`{"name":"si-max",` + gh + `,"sync_interval":2592001}`,
`{"name":"si-int32",` + gh + `,"sync_interval":2147483648}`,
`{"name":"si-rpm","package_type":"rpm","base_url":"https://example.com/repo","sync_interval":60}`,
} {
if c := do(t, h, "POST", "/", body); c != 400 {