[PR #6263] [MERGED] [client, management, misc] expose VCS revision in dev build version output #25230

Closed
opened 2026-08-05 07:05:43 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6263
Author: @riccardomanfrin
Created: 5/26/2026
Status: Merged
Merged: 6/3/2026
Merged by: @riccardomanfrin

Base: mainHead: feat/dev_version_commit_sha


📝 Commits (6)

  • 67e4a13 Refactor to use a common checker for development version
  • 461f1cd Adds commit sha to development version for cobra command only
  • c820a3a Adjust for "v0.31.1-dev" test case
  • 0546c55 Drop synthetic "dev"/"0.50.0-dev" firewall feature-gate fixtures
  • 496c459 Remove unexistent tests on wire format
  • a23722f Adds tests for IsDevelopmentVersion

📊 Changes

9 files changed (+102 additions, -45 deletions)

View changed files

📝 client/cmd/version.go (+7 -1)
📝 client/internal/lazyconn/support.go (+3 -1)
📝 client/internal/updater/manager.go (+1 -3)
📝 management/internals/controllers/network_map/controller/controller.go (+2 -1)
📝 management/server/peer.go (+2 -1)
📝 management/server/types/account.go (+2 -1)
📝 management/server/types/account_test.go (+1 -35)
📝 version/version.go (+58 -2)
version/version_test.go (+26 -0)

📄 Description

The revision is read from debug.ReadBuildInfo() (already embedded by go build since Go 1.18) and rendered only at the CLI layer; the wire format reported to the management server is unchanged.

Implementation:

  • version.NetbirdVersion() still returns the literal "development" for dev builds. Management server, dashboard peer.version === "development" feature probes, gRPC Meta.NetbirdVersion, User-Agent headers — all unaffected.
  • New version.NetbirdCommit() returns the 12-char revision (with -dirty suffix when the working tree was modified) or an empty string when no VCS info is embedded. Used only by client/cmd/version.go.
  • New version.IsDevelopmentVersion() predicate (HasPrefix("development")) replaces ad-hoc == "development" and strings.Contains(v, "dev") checks in:
    • client/internal/lazyconn/support.go
    • client/internal/updater/manager.go
    • management/internals/controllers/network_map/controller/controller.go
    • management/server/peer.go
    • management/server/types/account.go
  • The CLI gates commit appending on IsDevelopmentVersion(), so release builds (version=0.50.0) still print 0.50.0, not 0.50.0-<sha> — goreleaser does not pass -buildvcs=false, so VCS info is also embedded in release binaries.

Notes for reviewers

  • IsDevelopmentVersion uses HasPrefix("development") and intentionally does not match tagged prereleases like v0.31.1-dev (existing lazyconn/support_test.go fixture covers this).
  • Semantic narrowing for management/server/peer.go and management/server/types/account.go: previously both used strings.Contains(v, "dev"), which also matched tagged prereleases like "1.0.0-dev" or bare "dev". After migration to IsDevelopmentVersion, only "development"-prefixed values trigger the dev bypass (min-version check on remote jobs, firewall feature unlock). Existing fixtures in management/server/types/account_test.go:654,671 ("0.50.0-dev", "dev") encode the old loose behavior and have been removed: flagging for team discussion before merge.
  • While this change does not change the CLI semantic (I've checked the box below) it changes the output of netbird version for dev builds

N/A — internal DX improvement.

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

CLI output extension only; no user-facing flag or behavior change documented elsewhere.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

  • New Features

    • Version command now displays commit identifier for development builds
  • Improvements

    • Standardized development version detection across the application for more consistent behavior

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6263 **Author:** [@riccardomanfrin](https://github.com/riccardomanfrin) **Created:** 5/26/2026 **Status:** ✅ Merged **Merged:** 6/3/2026 **Merged by:** [@riccardomanfrin](https://github.com/riccardomanfrin) **Base:** `main` ← **Head:** `feat/dev_version_commit_sha` --- ### 📝 Commits (6) - [`67e4a13`](https://github.com/netbirdio/netbird/commit/67e4a137131d13acf293a754f06a39cbb047b936) Refactor to use a common checker for development version - [`461f1cd`](https://github.com/netbirdio/netbird/commit/461f1cd96a3526cf2ee298abbeddbbf399f35ec4) Adds commit sha to development version for cobra command only - [`c820a3a`](https://github.com/netbirdio/netbird/commit/c820a3a7f39154c9853fe3efbacd62a53a039c80) Adjust for "v0.31.1-dev" test case - [`0546c55`](https://github.com/netbirdio/netbird/commit/0546c55b1af43f4ed08d025ac1633fc5b4fe5b11) Drop synthetic "dev"/"0.50.0-dev" firewall feature-gate fixtures - [`496c459`](https://github.com/netbirdio/netbird/commit/496c459870fd42aa5f84fdeb5c8b2b37f4f30f5c) Remove unexistent tests on wire format - [`a23722f`](https://github.com/netbirdio/netbird/commit/a23722f459cb55d50f319dfe992815115d049281) Adds tests for IsDevelopmentVersion ### 📊 Changes **9 files changed** (+102 additions, -45 deletions) <details> <summary>View changed files</summary> 📝 `client/cmd/version.go` (+7 -1) 📝 `client/internal/lazyconn/support.go` (+3 -1) 📝 `client/internal/updater/manager.go` (+1 -3) 📝 `management/internals/controllers/network_map/controller/controller.go` (+2 -1) 📝 `management/server/peer.go` (+2 -1) 📝 `management/server/types/account.go` (+2 -1) 📝 `management/server/types/account_test.go` (+1 -35) 📝 `version/version.go` (+58 -2) ➕ `version/version_test.go` (+26 -0) </details> ### 📄 Description The revision is read from `debug.ReadBuildInfo()` (already embedded by `go build` since Go 1.18) and rendered only at the CLI layer; the wire format reported to the management server is unchanged. Implementation: - `version.NetbirdVersion()` still returns the literal `"development"` for dev builds. Management server, dashboard `peer.version === "development"` feature probes, gRPC `Meta.NetbirdVersion`, User-Agent headers — all unaffected. - New `version.NetbirdCommit()` returns the 12-char revision (with `-dirty` suffix when the working tree was modified) or an empty string when no VCS info is embedded. Used only by `client/cmd/version.go`. - New `version.IsDevelopmentVersion()` predicate (`HasPrefix("development")`) replaces ad-hoc `== "development"` and `strings.Contains(v, "dev")` checks in: - `client/internal/lazyconn/support.go` - `client/internal/updater/manager.go` - `management/internals/controllers/network_map/controller/controller.go` - `management/server/peer.go` - `management/server/types/account.go` - The CLI gates commit appending on `IsDevelopmentVersion()`, so release builds (`version=0.50.0`) still print `0.50.0`, not `0.50.0-<sha>` — goreleaser does not pass `-buildvcs=false`, so VCS info is also embedded in release binaries. ### Notes for reviewers - `IsDevelopmentVersion` uses `HasPrefix("development")` and intentionally does **not** match tagged prereleases like `v0.31.1-dev` (existing `lazyconn/support_test.go` fixture covers this). - **Semantic narrowing for `management/server/peer.go` and `management/server/types/account.go`**: previously both used `strings.Contains(v, "dev")`, which also matched tagged prereleases like `"1.0.0-dev"` or bare `"dev"`. After migration to `IsDevelopmentVersion`, only `"development"`-prefixed values trigger the dev bypass (min-version check on remote jobs, firewall feature unlock). Existing fixtures in `management/server/types/account_test.go:654,671` (`"0.50.0-dev"`, `"dev"`) encode the old loose behavior and have been removed: flagging for team discussion before merge. - While this change does not change the CLI semantic (I've checked the box below) it changes the output of `netbird version` for dev builds ## Issue ticket number and link N/A — internal DX improvement. ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [x] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — **OR** I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#discuss-changes-with-the-netbird-team-first). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) CLI output extension only; no user-facing flag or behavior change documented elsewhere. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/__ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Version command now displays commit identifier for development builds * **Improvements** * Standardized development version detection across the application for more consistent behavior <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/netbirdio/netbird/pull/6263?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 07:05:43 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#25230