Skip to content

web: resolve related-entity names on facility detail#22

Merged
dotwaffle merged 1 commit into
mainfrom
facility-detail-related-names
Jun 8, 2026
Merged

web: resolve related-entity names on facility detail#22
dotwaffle merged 1 commit into
mainfrom
facility-detail-related-names

Conversation

@dotwaffle

Copy link
Copy Markdown
Owner

Problem

On a facility detail page (e.g. /ui/fac/181, Global Switch Paris), every carrier rendered as "Global Switch Paris" — the facility's own name. The same bug affected the networks list (masked because each row also shows its ASN) and the terminal/JSON IXP list.

Root cause: PeeringDB's association objects (carrierfac, netfac, ixfac) set their name field to the facility's name, not the related entity's. Confirmed against the live API — fac 181's 5 carrierfac rows have distinct carrier_ids but every name is "Global Switch Paris". The web UI used that join name directly as the carrier/network/exchange name.

Fix

Resolve the names from the related-entity edge (WithCarrier/WithNetwork/WithInternetExchange) instead of the association row's name. This corrects:

  • Browser fragmentshandleFacNetworksFragment, handleFacCarriersFragment (the IXP fragment already used the edge).
  • Terminal/JSON pathqueryFacility (all three sections, including IXPs).

Also fixed ordering: the old ByName() sorts on the constant facility name, so the "pre-sorted alphabetically" carrier/IXP sections were effectively unordered. Now they order by the related entity's name via the generated edge-field order helpers.

The /api, REST, GraphQL, and gRPC surfaces are intentionally untouched — there carrierfac.name == facility name is the correct upstream contract (drop-in parity). This was solely a web-UI presentation bug.

Tests

The seed and assertions previously encoded the bug (the fragment test asserted the carrier row equalled the facility name). Updated the seed so all three association rows carry the facility name as upstream does, added TestQueryFacility_RelatedEntityNames, and added negative guards that the facility name no longer leaks as a related-entity name.

go test -race ./..., go vet ./..., and golangci-lint run all pass; no generated-code drift.

🤖 Generated with Claude Code

PeeringDB's association objects (carrierfac, netfac, ixfac) carry a
`name` field set to the facility's name, not the related entity's. The
facility detail page used that join `name` directly as the carrier,
network, and exchange name, so every related row rendered the facility's
own name. On a facility like Global Switch Paris, all carriers (and all
networks) displayed "Global Switch Paris" instead of their real names.

Resolve the names from the related-entity edge instead: load Carrier,
Network, and InternetExchange via WithCarrier/WithNetwork/
WithInternetExchange and read the edge's name. This affects both the
browser fragments (handleFac{Networks,Carriers}Fragment) and the
terminal/JSON path (queryFacility); the IXP fragment already used the
edge, but queryFacility did not.

The previous ordering used ByName(), which sorts on the constant
facility name and left the "pre-sorted alphabetically" sections
effectively unordered. Order by the related entity's name via the
generated edge-field order helpers so the carrier and IXP lists are
genuinely alphabetical.

The /api, REST, GraphQL, and gRPC surfaces are intentionally untouched:
there carrierfac.name == facility name is the correct upstream contract.
This was solely a web-UI presentation bug.

The test seed encoded the bug (the ixfac row's name was set to the IX
name, and the fragment assertions expected the facility name as the
carrier/network name). Seed all three association rows with the facility
name, as upstream does, and assert the related-entity names with
negative guards that the facility name no longer leaks.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Code Metrics Report

Coverage Test Execution Time
80.8% 2m17s

Code coverage of files in pull request scope (69.7%)

Files Coverage
internal/web/detail.go 67.9%
internal/web/query_facility.go 82.2%

Reported by octocov

@dotwaffle dotwaffle merged commit feef221 into main Jun 8, 2026
2 checks passed
@dotwaffle dotwaffle deleted the facility-detail-related-names branch June 8, 2026 11:32
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