From 1b866598c4ed1410232c3e3a0ea9abc5e453f598 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Fri, 28 Nov 2025 06:07:20 +0000 Subject: [PATCH] Fix agent self-update infinite loop due to version prefix mismatch The agent's CurrentVersion includes the "v" prefix (e.g., "v4.33.1") but the server's /api/agent/version endpoint returns versions without it (e.g., "4.33.1"). This caused the comparison to always fail, triggering an infinite self-update loop every 30 seconds. Normalize both versions by stripping the "v" prefix before comparison. Related to #740 --- internal/agentupdate/update.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/agentupdate/update.go b/internal/agentupdate/update.go index 6c3bcf7e9..61451619a 100644 --- a/internal/agentupdate/update.go +++ b/internal/agentupdate/update.go @@ -156,7 +156,10 @@ func (u *Updater) CheckAndUpdate(ctx context.Context) { return } - if serverVersion == u.cfg.CurrentVersion { + // Normalize both versions by stripping "v" prefix for comparison. + // Server returns version without prefix (e.g., "4.33.1"), but agent's + // CurrentVersion may include it (e.g., "v4.33.1") depending on build. + if normalizeVersion(serverVersion) == normalizeVersion(u.cfg.CurrentVersion) { u.logger.Debug().Str("version", u.cfg.CurrentVersion).Msg("Agent is up to date") return } @@ -437,6 +440,11 @@ func (u *Updater) performUpdate(ctx context.Context) error { return nil } +// normalizeVersion strips the "v" prefix from version strings for comparison. +func normalizeVersion(version string) string { + return strings.TrimPrefix(strings.TrimSpace(version), "v") +} + // determineArch returns the architecture string for download URLs (e.g., "linux-amd64", "darwin-arm64"). func determineArch() string { os := runtime.GOOS