Fix agent infinite update loop on dev builds

The /api/agent/version endpoint was returning the git-describe version
(e.g. 6.0.0-rc.2+git.58.g53a9339.dirty) for dev builds, which is always
semantically newer than the binary's embedded version (v6.0.0-rc.1).
This caused agents to loop: check version → see "newer" → self-update →
restart → still same binary version → loop again.

The agent's guard ("skip if server reports 'dev'") only fires for the
literal string "dev". Fix: return "dev" whenever IsDevelopment is true,
which covers all git-built/dirty dev instances.
This commit is contained in:
rcourtman
2026-04-18 20:42:12 +01:00
parent 53a9339e4e
commit 8f133b1be1
+4 -2
View File
@@ -4866,9 +4866,11 @@ func (r *Router) handleAgentVersion(w http.ResponseWriter, req *http.Request) {
return
}
// Return the server version - all agents should match the server version
// Return the server version - all agents should match the server version.
// Dev/git builds return "dev" so agents don't enter an infinite update loop
// (the agent skips updates when the server reports "dev").
version := "dev"
if versionInfo, err := updates.GetCurrentVersion(); err == nil {
if versionInfo, err := updates.GetCurrentVersion(); err == nil && !versionInfo.IsDevelopment {
version = versionInfo.Version
}