Skip to content

pdbcompat: /api/ index parity + root build-version banner (v1.20.6)#30

Merged
dotwaffle merged 3 commits into
mainfrom
root-json-version
Jun 8, 2026
Merged

pdbcompat: /api/ index parity + root build-version banner (v1.20.6)#30
dotwaffle merged 3 commits into
mainfrom
root-json-version

Conversation

@dotwaffle

Copy link
Copy Markdown
Owner

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 emits
    upstream's {"data":[{"<type>":"<absolute-url>",...}],"meta":{}} with absolute
    list-endpoint URLs built from the request host, so a drop-in client can follow
    them directly. Upstream's 14th endpoint as_set (a bulk asn → irr_as_set
    dump) stays unmirrored and is omitted from the index so it never advertises a
    dead link — documented as a Known Divergence.
  • Root / banner → real build version. Served a hardcoded
    "version":"0.1.0" and never read internal/buildinfo, even though
    Dockerfile.prod already injects git describe via -ldflags (the prod build
    logs confirm Building peeringdb-plus version=v1.20.5). Now reflects the
    deployed build. Go's debug.ReadBuildInfo records only the commit, never the
    tag, which is why the tag must be injected.

Tests

TestIndex rewritten to assert the upstream envelope + absolute URLs;
TestDiscoveryBody added to guard the dynamic version. go build, go vet,
go test -race ./internal/pdbcompat/... ./cmd/peeringdb-plus/..., and
golangci-lint all pass.

🤖 Generated with Claude Code

dotwaffle added 3 commits June 8, 2026 16:34
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.
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Code Metrics Report

Coverage Test Execution Time
80.6% 2m28s

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

Files Coverage
cmd/peeringdb-plus/main.go 35.2%
internal/pdbcompat/handler.go 93.2%

Reported by octocov

@dotwaffle dotwaffle merged commit d559b9c into main Jun 8, 2026
2 checks passed
@dotwaffle dotwaffle deleted the root-json-version branch June 8, 2026 16:48
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