Skip to content

fix(chain-aliases): apply matchesChainSlug across all 9 sites - #724

Merged
Flotapponnier merged 1 commit into
mainfrom
fix/chain-slug-aliasing-comprehensive
Jun 25, 2026
Merged

fix(chain-aliases): apply matchesChainSlug across all 9 sites#724
Flotapponnier merged 1 commit into
mainfrom
fix/chain-slug-aliasing-comprehensive

Conversation

@Flotapponnier

Copy link
Copy Markdown
Collaborator

Fixes the 404 on /benchmarks/wallet-labels-coverage/gram (and 8 other places) reported by the user. Follow-up to #708 / #711 — the alias system existed but was only applied to 3 sites. Every other strict === chain comparison still missed.

New helper

matchesChainSlug(a, b) in chain-aliases.ts — case-insensitive, both args nullable, resolves both sides through canonicalChainSlug.

Patched

  • chain page route (perChainExplainer + results + dimensions + region variants)
  • badge API + variant API (rejected ?chain=gram with 'unknown chain')
  • share-card + opengraph-image + twitter-image (chain label render)
  • benchmark-body client filter (?chain URL param)
  • chains hub page (per-bench routing detection)
  • sitemap (canonicalize before emit so we don't ship /ton URLs that 308)

Test plan

  • /benchmarks/wallet-labels-coverage/gram → 200
  • /benchmarks/wallet-labels-coverage/ton → 308 → above (already from rename chain slug ton → gram + 301 redirects + Prom straddle #705)
  • /chains/gram → list still includes wallet-labels (was already fine via getBenchmarksForChain)
  • ?chain=gram on any bench → tab selected correctly, no 'unknown chain'
  • /api/badge//?chain=gram → 200, label is 'Gram'
  • /api/og/?chain=gram → image shows 'on Gram'
  • sitemap.xml → /benchmarks//gram URLs (not /ton)

Follow-up to #708 / #711. The alias system was added but only applied
to getBenchmarksForChain + ChainHeadingsSummary + overlayEditorial.
Every other place that did a strict-equality chain-slug match still
404'd or rendered wrong when called with the canonical slug ('gram')
while the YAML dimension / result row still held the legacy slug
('ton'). The user hit /benchmarks/wallet-labels-coverage/gram and got
a 404.

This PR pushes matchesChainSlug into every site that does a slug ===
match on a chain.

New helper in src/lib/chain-aliases.ts:
- matchesChainSlug(a, b) — both args optional, case-insensitive,
  resolves both sides through canonicalChainSlug. Replaces every
  '=== chain' on a chain-slug.
- chainSlugSiblings(slug) — returns the set { canonical, ...legacy }
  for use as a filter Set.

Patched 9 surfaces:
- src/app/benchmarks/[slug]/[chain]/page.tsx — perChainExplainer
  lookup, results.find (row shape), dimensions.find (dimension shape),
  region variant fetch. /benchmarks/wallet-labels-coverage/gram now
  resolves.
- src/app/api/badge/[slug]/[provider]/route.ts — chainLabel + cell
  param resolution. Badge endpoint accepts ?chain=gram.
- src/app/api/bench/[slug]/variant/route.ts — variant filter
  validation. ?chain=gram no longer returns 'unknown chain'.
- src/app/benchmarks/[slug]/share-card/route.tsx — OG share card
  chain pill resolution.
- src/components/benchmark-body.tsx — client-side initial tab
  selection from ?chain= URL param.
- src/app/chains/[slug]/page.tsx — per-bench dimension/result/route
  detection on the chain hub.
- src/app/benchmarks/[slug]/opengraph-image.tsx — chain label on OG
  image.
- src/app/benchmarks/[slug]/twitter-image.tsx — same for Twitter
  cards.
- src/app/sitemap.ts — emits canonical slug URLs (/gram) instead of
  legacy (/ton) so crawlers don't waste budget on 308s. Per-chain
  explainer filter uses canonical comparison.

What is NOT in this PR (deliberately):
- Schema change to dimensions (value/prom_value/aliases) — too much
  surface, deferred to a separate refactor once harness rotates.
- Harness Go code update (chain='ton' → 'gram' label) — separate
  Railway redeploy.
- middleware-level URL canonicalization — next.config.ts redirects
  already cover the legacy /ton URLs; middleware adds nothing right
  now.
@Flotapponnier
Flotapponnier merged commit 94f66fe into main Jun 25, 2026
@Flotapponnier
Flotapponnier deleted the fix/chain-slug-aliasing-comprehensive branch July 17, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant