Repository navigation
feat: report the version in a Nanopub-Router-Version header - #17
Open
ashleycaselli wants to merge 1 commit into
Open
ashleycaselli wants to merge 1 commit into
ashleycaselli wants to merge 1 commit into
Conversation
The Nanopub Monitor fills its version column from a per-service response header, reading Nanopub-Registry-Version, Nanopub-Query-Version and Nanodash-Version from the instances it scans. The router sent no such header, so a router instance would show up there with an empty version. Set Nanopub-Router-Version on every response, following that convention. It is applied as middleware before the handler runs, so it survives handlers that write their status immediately: the 307 redirects, and the 503 that /healthz returns for a missing or stale snapshot. An instance that cannot route is exactly when knowing which build answered is most useful. The value is injected at build time with -ldflags "-X main.version=...", from a VERSION build arg that the release pipeline sets from the release tag. A plain "go build" keeps reporting "dev". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NnGpEQkFqCaf4AEQwwhFFn
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.
Groundwork for showing the router in the Nanopub Monitor.
Why
The monitor fills its version column from a per-service response header —
ServerScannerreadsNanopub-Registry-Version,Nanopub-Query-Version,Nanopub-Monitor-VersionandNanodash-Versionfrom the instances it scans. The router sends no such header, so a router instance listed there would show an empty version.Changes
Nanopub-Router-Versionon every response, via awithVersionHeadermiddleware alongside the existingwithAccessLog.versionis injected at build time with-ldflags "-X main.version=..."from aVERSIONbuild arg;release.config.jspasses${nextRelease.version}todocker buildx build. A plaingo buildstill reportsdev.The header is set before the handler runs, so it survives handlers that write their status immediately — the
307redirects, and the503/healthzreturns for a missing or stale snapshot. That last case is the point: an instance that cannot route is exactly when you want to know which build answered.Verified
Built with an injected version and exercised the running binary:
Three tests added, covering the help page,
/healthz, a307redirect, the unhealthy503path, and thatversionis never empty.go test ./...andgo vet ./...both clean.Note
gofmtreportsmain.goas unformatted — struct field alignment inConfig, which predates this branch and is untouched here. CI runs onlygo test, so nothing fails. Happy to fix it in a separate whitespace-only PR rather than muddying this diff.Not included
This only makes the router reportable. Two further pieces are needed before it actually appears in the monitor, and neither is in this PR:
nanopub-routerbranch in the monitor'sServerScannerthat probes/healthzrather than falling through to the genericGET /probe. Worth doing:/is the help page and always returns 200, so the generic probe would report a router with a stale snapshot as healthy.🤖 Generated with Claude Code
https://claude.ai/code/session_01NnGpEQkFqCaf4AEQwwhFFn