Skip to content

fix(markets): restore sector valuation enrichment after Yahoo 401s #5903

Description

@koala73

Summary

Production publishes all 12 sector price records, but valuation enrichment is completely absent. Both the direct Yahoo quoteSummary request and the Decodo proxy fallback return HTTP 401, so every five-minute cycle writes market:sectors:v2 with 0 valuations while reporting Redis success.

This is a persistent partial-coverage bug, not a total market-data outage: price changes remain available, but trailing/forward P/E, beta, YTD return, three-year return, and five-year return are missing for every sector ETF.

Priority: P2. Core 12/12 sector prices remain available, but an entire enrichment dimension is continuously lost and current health semantics mask it.

Production evidence

Observed on Railway production on 2026-07-31.

Three consecutive cycles:

2026-07-31T05:22:24Z [Market] Seeded 12/12 sectors, 0 valuations (redis: OK)
2026-07-31T05:27:27Z [Market] Seeded 12/12 sectors, 0 valuations (redis: OK)
2026-07-31T05:32:34Z [Market] Seeded 12/12 sectors, 0 valuations (redis: OK)

Latest bounded 15-minute sample:

  • 46 direct Yahoo quoteSummary <symbol> HTTP 401 log entries
  • 10 proxy Yahoo quoteSummary <symbol> proxy HTTP 401 log entries
  • proxy cooldown activates after repeated failures
  • sector price publishing remains 12/12 and Redis writes remain OK

No overlapping WorldMonitor issue or pull request was found using searches for sector valuation, quoteSummary, 0 valuations, and Yahoo 401.

Current code path

scripts/ais-relay.cjs:

  • fetchYahooQuoteSummary() calls Yahoo /v10/finance/quoteSummary/<symbol> directly.
  • _yahooQuoteSummaryProxyFallback() retries the same endpoint through Decodo.
  • seedSectorSummary() accepts an empty valuations object and still publishes the 12 sector price records and healthy seed metadata.

Because direct and proxy egress receive the same 401 class, repeatedly retrying this route is not a credible restoration strategy.

Impact

  • market:sectors:v2 has current sector price changes but no valuation records.
  • UI, bootstrap, and MCP consumers can present sector performance while silently lacking valuation context.
  • seed-meta:market:sectors records only the 12 price rows, so health cannot distinguish full coverage from 12 prices plus 0 valuations.
  • The relay generates repeated provider-error noise and unnecessary proxy traffic every five minutes.

Scope

Diagnose the Yahoo authentication/endpoint behavior from Railway and restore valuation enrichment using a sustainable route or provider. Do not merely add more retries to the same direct/proxy request.

Preserve truthful partial-coverage semantics if valuation data is temporarily unavailable. A last-good valuation fallback is acceptable only with explicit source timestamp and stale/degraded status.

Acceptance criteria

  • Reproduce and classify the direct and proxy 401 responses without exposing proxy credentials.
  • Restore valuation data for representative sector ETFs such as XLK, XLF, and XLE through a sustainable route/provider.
  • Verify non-empty valuation output across at least two consecutive production cycles.
  • Publish valuation coverage count and source status separately from the 12 price-record count.
  • Health or seed metadata marks 0 valuation coverage as degraded instead of treating 12/12 sectors, 0 valuations as fully healthy.
  • If last-good valuations are preserved, their source timestamp and stale state are explicit.
  • Tests cover direct 401 plus proxy 401, partial valuation coverage, total valuation loss, and recovery.
  • Relay logs remain bounded and do not retry the same known-failing route indefinitely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority, schedule when capacity allowsarea: infrastructureCables, pipelines, power grids, cyber threatsarea: marketsMarkets, commodities, crypto, financebugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions