pdbcompat: /api/ index parity + root build-version banner (v1.20.6)#30
Merged
Conversation
GET / served a hardcoded "version":"0.1.0" and never consulted internal/buildinfo, even though Dockerfile.prod already injects `git describe --tags --always --dirty` into it via -ldflags (the prod build logs confirm "Building peeringdb-plus version=v1.20.5"). Go's debug.ReadBuildInfo records only the commit, never the tag, which is why the version is injected at build time rather than read at runtime. Extract a small discoveryBody(version) helper fed by buildinfo.Version() so the root banner reflects the deployed build instead of a stale constant. Add a unit test guarding the dynamic interpolation.
The /api/ index returned a peeringdb-plus-specific shape —
{"<type>":{"list_endpoint":"/api/<type>"},...} with relative paths — that
does not match upstream PeeringDB's index:
{"data":[{"<type>":"<absolute-url>",...}],"meta":{}}. Reshape serveIndex
to the upstream envelope, building absolute list-endpoint URLs from the
request scheme + host so a drop-in client can follow them directly. The
index is now built per request (the host is request-derived) rather than
once at init, dropping the static indexBody and its slices/maps use.
Upstream additionally lists `as_set` (a network-derived AS-SET lookup
this mirror does not serve); the index lists only the 13 served types so
it never advertises a dead link. The as_set gap is captured as a Known
Divergence.
Add the as_set Known Divergence row (upstream's 14th /api/ endpoint, a
bulk asn -> irr_as_set dump that this mirror does not serve), note the
upstream `{data:[{type:url}],meta:{}}` envelope on the /api/ index
overview line, and roll the changelog for v1.20.6 — the /api/ index
format match and the root-JSON build-version banner.
Code Metrics Report
Code coverage of files in pull request scope (49.2%)
Reported by octocov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two small upstream-fidelity fixes for the root/index surfaces, surfaced while
wiring the build version into the service banner. Released as v1.20.6.
Fixes
/api/index → upstream shape. Was peeringdb-plus-specific(
{"<type>":{"list_endpoint":"/api/<type>"},...}, relative paths); now emitsupstream's
{"data":[{"<type>":"<absolute-url>",...}],"meta":{}}with absolutelist-endpoint URLs built from the request host, so a drop-in client can follow
them directly. Upstream's 14th endpoint
as_set(a bulkasn → irr_as_setdump) stays unmirrored and is omitted from the index so it never advertises a
dead link — documented as a Known Divergence.
/banner → real build version. Served a hardcoded"version":"0.1.0"and never readinternal/buildinfo, even thoughDockerfile.prodalready injectsgit describevia-ldflags(the prod buildlogs confirm
Building peeringdb-plus version=v1.20.5). Now reflects thedeployed build. Go's
debug.ReadBuildInforecords only the commit, never thetag, which is why the tag must be injected.
Tests
TestIndexrewritten to assert the upstream envelope + absolute URLs;TestDiscoveryBodyadded to guard the dynamic version.go build,go vet,go test -race ./internal/pdbcompat/... ./cmd/peeringdb-plus/..., andgolangci-lintall pass.🤖 Generated with Claude Code