fix(indexer): CoinGecko oracle User-Agent (#579) #1098

Merged
PlasticDigits merged 2 commits from fix/579-coingecko-user-agent into main 2026-08-20 03:17:28 +00:00
PlasticDigits commented 2026-08-20 01:38:55 +00:00 (Migrated from gitlab.com)

Summary

  • CoinGecko free API was returning HTTP 403 (Please add a descriptive User-Agent) because the oracle reqwest client set timeout only.
  • The oracle HTTP client now sends a stable cl8y-dex-indexer/<version> (+https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic) User-Agent on KuCoin / MEXC / CoinGecko polls (X7).
  • CoinGecko 403 User-Agent required maps to OracleError::MissingUserAgent (error once, then debug). 429 stays RateLimited (debug). Other 403s stay truncated parse/warn. Soft-fail averaging is unchanged.

Closes #579

Acceptance criteria

  • AC1. Oracle client sends a descriptive, non-browser User-Agent (indexer name + repo URL, CARGO_PKG_VERSION only).
  • AC2. Wiremock CG mocks require the user-agent header; tests fail if it is missing.
  • AC3. 429 → RateLimited; 403 User-Agent body is not 429 (MissingUserAgent). Other 403 → Parse, truncated.
  • AC4. Poll loop unchanged aside from headers/error mapping. Alternate-tick CG, ticker ids, $1 peg, and catalog paths untouched.
  • AC5. Runbook, skill, and docs/indexer-invariants.md document UA + 403 vs 429. make verify-issue-579 green without live CoinGecko.

Test plan (recorded)

# Path Result
T1 CG 200 + UA matcher Pass (fetch_coingecko_sends_descriptive_user_agent)
T2 Mock requires UA header Pass (production client; AC2)
T3 CG 429 Pass (RateLimited)
T4 CG 403 UA body Pass (MissingUserAgent; 1.0 USD in body not ingested)
T5 CG 403 other Pass (Parse, truncated)
T6 CG 500 / missing .usd Pass
T7 Alternate tick Pass (include_coingecko_on_tick)
T8/T9 vFDUSD no KuCoin; USTC/LUNC ids Existing ticker tests unchanged
T10 Non-finite Existing f64_to_bd test
T11 KuCoin/MEXC with new default UA Same client; no live CEX in --lib oracle
T12 Docs make verify-issue-579 greps skill/runbook/invariants
A1–A8 No browser spoof, no env in UA, no rotation, truncate, no fake success Unit tests + code review

Verify

make verify-issue-579
# first pass + retest: docs greps + cargo test --lib oracle

X1–X6 ticker allowlists / $1 / volume_usd catalog were not changed. make verify-issue-515 (Postgres + frontend) was not re-run in this MR; --lib oracle still covers ticker symbol tests.

Docs

  • skills/AGENTS_INDEXER_EXTERNAL_ORACLE.md — X7, do/don't for UA vs 429
  • docs/runbooks/indexer-external-oracle.md — Sources table 403 vs 429
  • docs/indexer-invariants.md — CoinGecko User-Agent (#579) row
  • AGENTS.md — skill + make verify-issue-579

Closes #579

## Summary - CoinGecko free API was returning **HTTP 403** (`Please add a descriptive User-Agent`) because the oracle `reqwest` client set timeout only. - The oracle HTTP client now sends a stable `cl8y-dex-indexer/<version> (+https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic)` User-Agent on KuCoin / MEXC / CoinGecko polls (**X7**). - CoinGecko **403 User-Agent required** maps to `OracleError::MissingUserAgent` (error once, then debug). **429** stays `RateLimited` (debug). Other 403s stay truncated parse/warn. Soft-fail averaging is unchanged. Closes #579 ## Acceptance criteria - [x] **AC1.** Oracle client sends a descriptive, non-browser User-Agent (indexer name + repo URL, `CARGO_PKG_VERSION` only). - [x] **AC2.** Wiremock CG mocks require the `user-agent` header; tests fail if it is missing. - [x] **AC3.** 429 → `RateLimited`; 403 User-Agent body is **not** 429 (`MissingUserAgent`). Other 403 → Parse, truncated. - [x] **AC4.** Poll loop unchanged aside from headers/error mapping. Alternate-tick CG, ticker ids, `$1` peg, and catalog paths untouched. - [x] **AC5.** Runbook, skill, and `docs/indexer-invariants.md` document UA + 403 vs 429. `make verify-issue-579` green without live CoinGecko. ## Test plan (recorded) | # | Path | Result | |---|------|--------| | T1 | CG 200 + UA matcher | Pass (`fetch_coingecko_sends_descriptive_user_agent`) | | T2 | Mock requires UA header | Pass (production client; AC2) | | T3 | CG 429 | Pass (`RateLimited`) | | T4 | CG 403 UA body | Pass (`MissingUserAgent`; 1.0 USD in body not ingested) | | T5 | CG 403 other | Pass (Parse, truncated) | | T6 | CG 500 / missing `.usd` | Pass | | T7 | Alternate tick | Pass (`include_coingecko_on_tick`) | | T8/T9 | vFDUSD no KuCoin; USTC/LUNC ids | Existing ticker tests unchanged | | T10 | Non-finite | Existing `f64_to_bd` test | | T11 | KuCoin/MEXC with new default UA | Same client; no live CEX in `--lib oracle` | | T12 | Docs | `make verify-issue-579` greps skill/runbook/invariants | | A1–A8 | No browser spoof, no env in UA, no rotation, truncate, no fake success | Unit tests + code review | ## Verify ```bash make verify-issue-579 # first pass + retest: docs greps + cargo test --lib oracle ``` X1–X6 ticker allowlists / `$1` / `volume_usd` catalog were not changed. `make verify-issue-515` (Postgres + frontend) was not re-run in this MR; `--lib oracle` still covers ticker symbol tests. ## Docs - `skills/AGENTS_INDEXER_EXTERNAL_ORACLE.md` — **X7**, do/don't for UA vs 429 - `docs/runbooks/indexer-external-oracle.md` — Sources table 403 vs 429 - `docs/indexer-invariants.md` — CoinGecko User-Agent (#579) row - `AGENTS.md` — skill + `make verify-issue-579` Closes #579
PlasticDigits commented 2026-08-20 01:39:09 +00:00 (Migrated from gitlab.com)

marked this merge request as ready

marked this merge request as **ready**
PlasticDigits commented 2026-08-20 03:17:24 +00:00 (Migrated from gitlab.com)

added 7 commits

  • d317dee6...4068d8d4 - 6 commits from branch main
  • 94750756 - Merge origin/main into fix/579-coingecko-user-agent.

Compare with previous version

added 7 commits <ul><li>d317dee6...4068d8d4 - 6 commits from branch <code>main</code></li><li>94750756 - Merge origin/main into fix/579-coingecko-user-agent.</li></ul> [Compare with previous version](/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/380/diffs?diff_id=1972529069&start_sha=d317dee6ffee41e9dfee9a3d9f7360e2549ea74c)
PlasticDigits commented 2026-08-20 03:17:28 +00:00 (Migrated from gitlab.com)

mentioned in commit a30edba3c7

mentioned in commit a30edba3c7a6474482763c75554a9a6f8376d072
PlasticDigits (Migrated from gitlab.com) merged commit a30edba3c7 into main 2026-08-20 03:17:28 +00:00
PlasticDigits commented 2026-08-20 03:54:20 +00:00 (Migrated from gitlab.com)

mentioned in issue #579

mentioned in issue #579
PlasticDigits commented 2026-08-20 03:54:52 +00:00 (Migrated from gitlab.com)

mentioned in issue #583

mentioned in issue #583
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic!1098
No description provided.