Skip to content

feat(nats-auth-callout): expose GET /info endpoint - #711

Open
priyaselvaganesan wants to merge 3 commits into
mainfrom
feat/version-endpoint-nats-auth-callout
Open

feat(nats-auth-callout): expose GET /info endpoint#711
priyaselvaganesan wants to merge 3 commits into
mainfrom
feat/version-endpoint-nats-auth-callout

Conversation

@priyaselvaganesan

@priyaselvaganesan priyaselvaganesan commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

TL;DR

Adds GET /info to the nats-auth-callout gin router (port 8080), serving service name, version, and commit SHA via the shared go-lib handler.

Additional Details

  • r.engine.GET("/info", ...) for the handler, with explicit r.engine.Handle(method, "/info", ...) registrations for HEAD/POST/PUT/PATCH/DELETE/OPTIONS/CONNECT/TRACE returning 405 + Allow: GET. Method enforcement is scoped to /info only — other routes are unaffected.
  • Service, Version, and GitHash x_defs are injected at build time (--stamp) on the cmd/nvcf-nats-auth-callout-service binary. GitHash uses {STABLE_GIT_COMMIT_FULL} for the full 40-char SHA.
  • Adds go-lib as a new direct dependency. Go MVS pulls otel core to v1.44 and related transitive deps. Also aligns the pre-existing require google.golang.org/grpc v1.80.0 to v1.79.3 to match the existing replace directive.
  • Tests cover GET with exact stamped values, unstamped fallback to "unknown", and non-GET rejection on all 8 methods.

Testing

Built with Bazel, imported into ncp-local k3d, patched deployment/nvcf-nats-auth-callout-service, and verified via port-forward:

$ curl http://localhost:8083/info
{"service":"nvcf-nats-auth-callout-service","version":"mr-ea5bf574","commit":"ea5bf574eae1c2debe78a2ef8328e1bd5612e9a4"}

$ curl -X POST http://localhost:8083/info  ->  405 Method Not Allowed (Allow: GET)
$ curl http://localhost:8083/healthz        ->  200

Unit tests pass under both go test and bazel test.

References

Relates to #315

Summary by CodeRabbit

  • New Features

    • Added a /info endpoint that reports service version metadata.
    • Version responses now include stamped build details when available, with fallback values otherwise.
    • Unsupported HTTP methods receive a clear 405 Method Not Allowed response and indicate that only GET is supported.
  • Tests

    • Added coverage for version responses, fallback behavior, and unsupported request methods.

Signed-off-by: priyaselvaganesan <pselvaganesa@nvidia.com>
@priyaselvaganesan
priyaselvaganesan requested a review from a team as a code owner August 6, 2026 19:04
@priyaselvaganesan
priyaselvaganesan requested review from along-2017 and balajinvda and removed request for along-2017 August 6, 2026 19:04
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The NATS auth callout service now exposes a version-backed /info endpoint. Build stamping supplies service, release, and commit metadata. Tests verify stamped and fallback responses and non-GET rejection.

Changes

NATS auth callout service info endpoint

Layer / File(s) Summary
Build metadata and module wiring
src/control-plane-services/nats-auth-callout/cmd/.../BUILD.bazel, src/control-plane-services/nats-auth-callout/go.mod
Build stamping defines service, release, and Git commit values. Go dependencies include the shared library and updated module versions.
Info route registration
src/control-plane-services/nats-auth-callout/internal/router/router.go, src/control-plane-services/nats-auth-callout/internal/router/BUILD.bazel
The router registers GET /info with the shared version handler. Other listed methods return 405 with Allow: GET.
Info endpoint validation
src/control-plane-services/nats-auth-callout/internal/router/info_test.go, src/control-plane-services/nats-auth-callout/internal/router/BUILD.bazel
Tests verify stamped and fallback metadata responses and non-GET method rejection.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Router
  participant golibversion
  Client->>Router: Request GET /info
  Router->>golibversion: Serve version metadata
  golibversion-->>Router: Return JSON metadata
  Router-->>Client: Return HTTP response
  Client->>Router: Request non-GET /info
  Router-->>Client: Return 405 with Allow: GET
Loading

Possibly related PRs

  • NVIDIA/nvcf#591: Adds a stamped, GET-only /info endpoint with shared version metadata and method-rejection tests.
  • NVIDIA/nvcf#709: Adds a stamped, GET-only /info endpoint using the shared golibversion handler, Bazel wiring, and method-validation tests.
  • NVIDIA/nvcf#710: Adds a stamped /info endpoint with fallback behavior and explicit 405 handling.

Suggested reviewers: balajinvda, along-2017

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the required Conventional Commits format and accurately describes the new customer-facing GET /info endpoint.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/version-endpoint-nats-auth-callout

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/control-plane-services/nats-auth-callout/internal/router/info_test.go (1)

44-50: 🗄️ Data Integrity & Integration | 🔵 Trivial | 🏗️ Heavy lift

Assert the stamped metadata values.

The test accepts fallback values such as "unknown". A missing or miswired x_defs value can therefore pass. This does not verify the service name, semantic version, or full commit SHA returned by /info.

Add a stamped test with controlled values or an injectable handler, then assert the exact service, version, and commit fields. Keep this test for fallback behavior only if that behavior is also required.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/control-plane-services/nats-auth-callout/internal/router/info_test.go`
around lines 44 - 50, Update the /info test around the response unmarshalling to
inject controlled metadata values and assert exact service, version, and commit
values instead of only checking non-empty fields. Use the existing handler or
configuration injection point visible in the router tests, and retain the
fallback assertion only if fallback behavior is separately required.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/control-plane-services/nats-auth-callout/go.mod`:
- Line 111: Align the google.golang.org/grpc v1.80.0 requirement with its
replacement: either change the required version to v1.79.3 and document why the
replacement is intentional, or remove the replacement so v1.80.0 is used
directly.

---

Nitpick comments:
In `@src/control-plane-services/nats-auth-callout/internal/router/info_test.go`:
- Around line 44-50: Update the /info test around the response unmarshalling to
inject controlled metadata values and assert exact service, version, and commit
values instead of only checking non-empty fields. Use the existing handler or
configuration injection point visible in the router tests, and retain the
fallback assertion only if fallback behavior is separately required.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 45aa28a4-ea93-435e-a10c-161224c073c5

📥 Commits

Reviewing files that changed from the base of the PR and between 6bb0cde and eeddb44.

⛔ Files ignored due to path filters (1)
  • src/control-plane-services/nats-auth-callout/go.sum is excluded by !**/*.sum
📒 Files selected for processing (5)
  • src/control-plane-services/nats-auth-callout/cmd/nvcf-nats-auth-callout-service/BUILD.bazel
  • src/control-plane-services/nats-auth-callout/go.mod
  • src/control-plane-services/nats-auth-callout/internal/router/BUILD.bazel
  • src/control-plane-services/nats-auth-callout/internal/router/info_test.go
  • src/control-plane-services/nats-auth-callout/internal/router/router.go

Comment thread src/control-plane-services/nats-auth-callout/go.mod Outdated
…ethodNotAllowed, align grpc require to replace

Signed-off-by: priyaselvaganesan <pselvaganesa@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/control-plane-services/nats-auth-callout/internal/router/info_test.go`:
- Around line 33-41: Update TestInfoEndpoint_GET to capture the existing
golibversion.Service, golibversion.Version, and golibversion.GitHash values
before overwriting them, then restore those saved values in t.Cleanup instead of
clearing the globals. Follow the restoration pattern used by
TestInfoEndpoint_GET_UnstampedFallback.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7e5821f1-f467-493b-b2de-ec80bd8b9475

📥 Commits

Reviewing files that changed from the base of the PR and between eeddb44 and ea5bf57.

📒 Files selected for processing (4)
  • src/control-plane-services/nats-auth-callout/go.mod
  • src/control-plane-services/nats-auth-callout/internal/router/BUILD.bazel
  • src/control-plane-services/nats-auth-callout/internal/router/info_test.go
  • src/control-plane-services/nats-auth-callout/internal/router/router.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/control-plane-services/nats-auth-callout/internal/router/router.go
  • src/control-plane-services/nats-auth-callout/internal/router/BUILD.bazel

Comment on lines +33 to +41
func TestInfoEndpoint_GET(t *testing.T) {
golibversion.Service = "nvcf-nats-auth-callout-service"
golibversion.Version = "test-1.0.0"
golibversion.GitHash = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
t.Cleanup(func() {
golibversion.Service = ""
golibversion.Version = ""
golibversion.GitHash = ""
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Restore the prior version metadata.

TestInfoEndpoint_GET changes process-global metadata. Its cleanup always clears the values. This can overwrite state set before the test and make later tests depend on execution order.

Save golibversion.Service, golibversion.Version, and golibversion.GitHash before assignment. Restore those saved values in t.Cleanup, as TestInfoEndpoint_GET_UnstampedFallback does.

Proposed fix
 func TestInfoEndpoint_GET(t *testing.T) {
+	previousService := golibversion.Service
+	previousVersion := golibversion.Version
+	previousGitHash := golibversion.GitHash
 	golibversion.Service = "nvcf-nats-auth-callout-service"
 	golibversion.Version = "test-1.0.0"
 	golibversion.GitHash = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
 	t.Cleanup(func() {
-		golibversion.Service = ""
-		golibversion.Version = ""
-		golibversion.GitHash = ""
+		golibversion.Service = previousService
+		golibversion.Version = previousVersion
+		golibversion.GitHash = previousGitHash
 	})
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func TestInfoEndpoint_GET(t *testing.T) {
golibversion.Service = "nvcf-nats-auth-callout-service"
golibversion.Version = "test-1.0.0"
golibversion.GitHash = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
t.Cleanup(func() {
golibversion.Service = ""
golibversion.Version = ""
golibversion.GitHash = ""
})
func TestInfoEndpoint_GET(t *testing.T) {
previousService := golibversion.Service
previousVersion := golibversion.Version
previousGitHash := golibversion.GitHash
golibversion.Service = "nvcf-nats-auth-callout-service"
golibversion.Version = "test-1.0.0"
golibversion.GitHash = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
t.Cleanup(func() {
golibversion.Service = previousService
golibversion.Version = previousVersion
golibversion.GitHash = previousGitHash
})
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/control-plane-services/nats-auth-callout/internal/router/info_test.go`
around lines 33 - 41, Update TestInfoEndpoint_GET to capture the existing
golibversion.Service, golibversion.Version, and golibversion.GitHash values
before overwriting them, then restore those saved values in t.Cleanup instead of
clearing the globals. Follow the restoration pattern used by
TestInfoEndpoint_GET_UnstampedFallback.

…e global HandleMethodNotAllowed

Signed-off-by: priyaselvaganesan <pselvaganesa@nvidia.com>
http.MethodTrace,
} {
r.engine.Handle(method, "/info", infoMethodNotAllowed)
}

@along-2017 along-2017 Aug 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you may consider set engine.HandleMethodNotAllowed = true and gin handles 405 for all unregistered methods. In this case, this loop not needed anymore.

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.

2 participants