Skip to content

feat: add /version endpoint and global Minder-Version header#6358

Open
DharunMR wants to merge 1 commit intomindersec:mainfrom
DharunMR:add-version-endpoint
Open

feat: add /version endpoint and global Minder-Version header#6358
DharunMR wants to merge 1 commit intomindersec:mainfrom
DharunMR:add-version-endpoint

Conversation

@DharunMR
Copy link
Copy Markdown
Contributor

@DharunMR DharunMR commented Apr 13, 2026

Summary

This PR addresses the need to easily expose the Minder server's build version and commit hash for tooling and debugging purposes, as requested. It introduces a dedicated, unauthenticated /api/v1/version endpoint and adds a global gRPC Unary Interceptor to stamp the server version on all incoming HTTP/gRPC responses.

Changes Included

  • Protobuf: Added GetVersion RPC to HealthService mapped to GET /api/v1/version. Configured rpc_options to allow unauthenticated access (TARGET_RESOURCE_NONE).
  • Server Handler: Implemented the GetVersion logic to return constants.CLIVersion and constants.Revision.
  • Global Header: Created VersionHeaderInterceptor to inject the Minder-Version header into the response metadata for all requests.
  • Telemetry Fix: Replaced the hardcoded "v0.1.0" service version in initMetrics with the dynamic constants.CLIVersion.

How I Tested This

  1. Verified the new endpoint returns the correct JSON payload and header:
    curl -i http://localhost:8080/api/v1/version
  2. Verified that the global header is successfully injected into other pre-existing endpoints:
    curl -I http://localhost:8080/api/v1/health

swappy-20260422_092030

@DharunMR DharunMR requested a review from a team as a code owner April 13, 2026 15:49
@DharunMR DharunMR force-pushed the add-version-endpoint branch from c44ed8f to a1bff3a Compare April 13, 2026 15:53
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 13, 2026

Coverage Status

Coverage is 60.398%DharunMR:add-version-endpoint into mindersec:main. No base build found for mindersec:main.

@DharunMR DharunMR force-pushed the add-version-endpoint branch from a1bff3a to 4ade151 Compare April 13, 2026 16:16
Comment thread internal/controlplane/server.go Outdated
func VersionHeaderInterceptor() grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
// SetHeader tells gRPC-Gateway to add this to the HTTP response
_ = grpc.SetHeader(ctx, metadata.Pairs("x-minder-version", constants.CLIVersion))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RFC 6648 deprecates the "X-" prefix on headers, so just call this either "minder-version" or "server" (a standard header). If you use server, you might want to include the string "Minder" before the version.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, constants.ServerUserAgent might be exactly what you want.

Note that constants.CLIVersion only appears to be set via ldflags for CLI builds, not for the server. The Makefile and GitHub Actions is probably the right place to do this if you want to; you'll need to use GOFLAGS per https://ko.build/advanced/faq/#how-can-i-set-ldflags

Copy link
Copy Markdown
Contributor Author

@DharunMR DharunMR Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing me toward GOFLAGS the server binary now correctly stamp the version

swappy-20260422_092030

is commit hash required ??

@DharunMR DharunMR force-pushed the add-version-endpoint branch from 4ade151 to 5967607 Compare April 22, 2026 04:01
@DharunMR DharunMR changed the title feat: add /version endpoint and global X-Minder-Version header feat: add /version endpoint and global Minder-Version header Apr 22, 2026
@DharunMR DharunMR requested a review from evankanderson April 27, 2026 03:48
Signed-off-by: DharunMR <maddharun56@gmail.com>
@DharunMR DharunMR force-pushed the add-version-endpoint branch from 5967607 to 15b9407 Compare April 27, 2026 07:15
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.

Add a "/version" endpoint for Minder server

3 participants