[Bug] latest upstream version is wrongly detected #700

Closed
opened 2025-12-29 02:22:27 +01:00 by adam · 6 comments
Owner

Originally created by @christian-heusel on GitHub (May 2, 2024).

Is this a support request?

  • This is not a support request

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

2024-05-02T11:56:17Z WRN An updated version of Headscale has been found (0.23.0-alpha9 vs. your current v0.23.0-alpha11). Check it out https://github.com/juanfont/headscale/releases

Expected Behavior

No log message when on the latest version

Steps To Reproduce

  1. start up any headscale version later than 9
  2. observe the above warning

Environment

- OS: Debian trixie/sid with Headscale running in Docker
- Headscale version: v0.23.0-alpha11
- Tailscale version: -

Runtime environment

  • Headscale is behind a (reverse) proxy
  • Headscale runs in a container

Anything else?

With the relevant code inside of this project that is causing this behaviour being:
a9c568c801/cmd/headscale/cli/root.go (L72-L88)

I have dug into the issue/code a little and found that the error seems to propagate from github.com/hashicorp/go-version or alteast the version that the tcnksm/go-latest dependency is using. I have come to this conclusion with this little test program:

package main

import (
	"fmt"

	"github.com/hashicorp/go-version"
	"github.com/rs/zerolog/log"
	"github.com/tcnksm/go-latest"
)

func main() {
	Version := "v0.23.0-alpha10"
	githubTag := &latest.GithubTag{
		Owner:      "juanfont",
		Repository: "headscale",
	}

	fetch, err := githubTag.Fetch()
	fmt.Println("Valid")
	for _, v := range fetch.Versions {
		fmt.Printf("%s\n", v)
	}

	fmt.Println("Malformed")
	for _, v := range fetch.Malformeds {
		fmt.Printf("%s\n", v)
	}

	fmt.Println("Versioncmp")
	ourV, err := version.NewVersion(Version)
	theirV, err := version.NewVersion("0.23.0-alpha9")

	fmt.Printf("versioncompare %s < %s == %t\n", ourV, theirV, ourV.LessThan(theirV))

	// Original code
	res, err := latest.Check(githubTag, Version)
	if err == nil && res.Outdated {
		log.Warn().Msgf(
			"An updated version of Headscale has been found (%s vs. your current %s). Check it out https://github.com/juanfont/headscale/releases\n",
			res.Current,
			Version,
		)
	}
}

Gives the following:

$ go run test.go
Valid
0.23.0-alpha-docker-release-test
0.23.0-alpha11
0.23.0-alpha10
0.23.0-alpha9
0.23.0-alpha8
0.23.0-alpha7
0.23.0-alpha6
0.23.0-alpha5
0.23.0-alpha4
0.23.0-alpha4-docker-ko-test9
0.23.0-alpha4-docker-ko-test8
0.23.0-alpha4-docker-ko-test7
0.23.0-alpha4-docker-ko-test6
0.23.0-alpha4-docker-ko-test5
0.23.0-alpha4-docker-ko-test4
0.23.0-alpha4-docker-ko-test3
0.23.0-alpha4-docker-ko-test2
0.23.0-alpha4-docker-ko-test
0.23.0-alpha3
0.23.0-alpha2
0.23.0-alpha1
0.22.3
0.22.2
0.22.1
0.22.0
0.22.0-nfpmtest
0.22.0-alpha3
0.22.0-alpha2
0.22.0-alpha1
0.21.0
Malformed
Versioncmp
versioncompare 0.23.0-alpha10 < 0.23.0-alpha9 == true
{"level":"warn","time":"2024-05-02T14:30:27+02:00","message":"An updated version of Headscale has been found (0.23.0-alpha9 vs. your current v0.23.0-alpha10). Check it out https://github.com/juanfont/headscale/releases\n"}

This shows a few things:

  1. The versions greater than 9 are detected by latest
  2. They are parsed valid and not sorted out because they are malformed
  3. For some reason 0.23.0-alpha10 < 0.23.0-alpha9 is true
Originally created by @christian-heusel on GitHub (May 2, 2024). ### Is this a support request? - [X] This is not a support request ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current Behavior ``` 2024-05-02T11:56:17Z WRN An updated version of Headscale has been found (0.23.0-alpha9 vs. your current v0.23.0-alpha11). Check it out https://github.com/juanfont/headscale/releases ``` ### Expected Behavior No log message when on the latest version ### Steps To Reproduce 1. start up any headscale version later than 9 2. observe the above warning ### Environment ```markdown - OS: Debian trixie/sid with Headscale running in Docker - Headscale version: v0.23.0-alpha11 - Tailscale version: - ``` ### Runtime environment - [ ] Headscale is behind a (reverse) proxy - [X] Headscale runs in a container ### Anything else? With the relevant code inside of this project that is causing this behaviour being: https://github.com/juanfont/headscale/blob/a9c568c801a514855396c7dcec031b3598457f20/cmd/headscale/cli/root.go#L72-L88 I have dug into the issue/code a little and found that the error seems to propagate from `github.com/hashicorp/go-version` or alteast the version that the `tcnksm/go-latest` dependency is using. I have come to this conclusion with this little test program: ```golang package main import ( "fmt" "github.com/hashicorp/go-version" "github.com/rs/zerolog/log" "github.com/tcnksm/go-latest" ) func main() { Version := "v0.23.0-alpha10" githubTag := &latest.GithubTag{ Owner: "juanfont", Repository: "headscale", } fetch, err := githubTag.Fetch() fmt.Println("Valid") for _, v := range fetch.Versions { fmt.Printf("%s\n", v) } fmt.Println("Malformed") for _, v := range fetch.Malformeds { fmt.Printf("%s\n", v) } fmt.Println("Versioncmp") ourV, err := version.NewVersion(Version) theirV, err := version.NewVersion("0.23.0-alpha9") fmt.Printf("versioncompare %s < %s == %t\n", ourV, theirV, ourV.LessThan(theirV)) // Original code res, err := latest.Check(githubTag, Version) if err == nil && res.Outdated { log.Warn().Msgf( "An updated version of Headscale has been found (%s vs. your current %s). Check it out https://github.com/juanfont/headscale/releases\n", res.Current, Version, ) } } ``` Gives the following: ``` $ go run test.go Valid 0.23.0-alpha-docker-release-test 0.23.0-alpha11 0.23.0-alpha10 0.23.0-alpha9 0.23.0-alpha8 0.23.0-alpha7 0.23.0-alpha6 0.23.0-alpha5 0.23.0-alpha4 0.23.0-alpha4-docker-ko-test9 0.23.0-alpha4-docker-ko-test8 0.23.0-alpha4-docker-ko-test7 0.23.0-alpha4-docker-ko-test6 0.23.0-alpha4-docker-ko-test5 0.23.0-alpha4-docker-ko-test4 0.23.0-alpha4-docker-ko-test3 0.23.0-alpha4-docker-ko-test2 0.23.0-alpha4-docker-ko-test 0.23.0-alpha3 0.23.0-alpha2 0.23.0-alpha1 0.22.3 0.22.2 0.22.1 0.22.0 0.22.0-nfpmtest 0.22.0-alpha3 0.22.0-alpha2 0.22.0-alpha1 0.21.0 Malformed Versioncmp versioncompare 0.23.0-alpha10 < 0.23.0-alpha9 == true {"level":"warn","time":"2024-05-02T14:30:27+02:00","message":"An updated version of Headscale has been found (0.23.0-alpha9 vs. your current v0.23.0-alpha10). Check it out https://github.com/juanfont/headscale/releases\n"} ``` This shows a few things: 1. The versions greater than 9 are detected by latest 2. They are parsed valid and not sorted out because they are malformed 3. For some reason `0.23.0-alpha10 < 0.23.0-alpha9` is `true`
adam added the bug label 2025-12-29 02:22:27 +01:00
adam closed this issue 2025-12-29 02:22:27 +01:00
Author
Owner

@runejuhl commented on GitHub (May 17, 2024):

Looks like it's a known issue, here are some issues in the https://github.com/hashicorp/go-version/ tracker that look like they're related. Unfortunately one of them is almost 5 years old.

@runejuhl commented on GitHub (May 17, 2024): Looks like it's a known issue, here are some issues in the https://github.com/hashicorp/go-version/ tracker that look like they're related. Unfortunately one of them is almost 5 years old. + https://github.com/hashicorp/go-version/issues/92 + https://github.com/hashicorp/go-version/issues/59
Author
Owner

@github-actions[bot] commented on GitHub (Aug 16, 2024):

This issue is stale because it has been open for 90 days with no activity.

@github-actions[bot] commented on GitHub (Aug 16, 2024): This issue is stale because it has been open for 90 days with no activity.
Author
Owner

@christian-heusel commented on GitHub (Aug 16, 2024):

This issue is stale, but only because there has been no fix so far, the issue itself still persists 😊

@christian-heusel commented on GitHub (Aug 16, 2024): This issue is stale, but only because there has been no fix so far, the issue itself still persists 😊
Author
Owner

@kradalby commented on GitHub (Sep 5, 2024):

Thanks for the investigation, it looks like the easier proper way is to correct our incorrect use of semver.

we smash alpha and beta with the numbers, where it would be appropriate to have a . in between.

So we should do beta.4 for the next release and make sure we do alpha.1 and beta.1 for the next release.

I'm gonna close it as "this will be the solution". If that doesnt solve it we can reopen.

@kradalby commented on GitHub (Sep 5, 2024): Thanks for the investigation, it looks like the ~easier~ proper way is to correct our incorrect use of [semver](https://semver.org/#semantic-versioning-specification-semver). we smash alpha and beta with the numbers, where it would be appropriate to have a `.` in between. So we should do `beta.4` for the next release and make sure we do `alpha.1` and `beta.1` for the next release. I'm gonna close it as "this will be the solution". If that doesnt solve it we can reopen.
Author
Owner

@kradalby commented on GitHub (Sep 9, 2024):

Well this is fun:

https://github.com/juanfont/headscale/pull/2058#issuecomment-2338164724

I think that we are kind of in a catch22, and I think that just getting to the next version will actually solve this better than attempting to rename tags.

From reading semver, we are now using the right approach, but the library likely does not parse things after the . when the number is in the same as the beta.

Hopefully this should be solved by doing a RC in a couple of days.

@kradalby commented on GitHub (Sep 9, 2024): Well this is fun: https://github.com/juanfont/headscale/pull/2058#issuecomment-2338164724 I think that we are kind of in a catch22, and I think that just getting to the next version will actually solve this better than attempting to rename tags. From reading semver, we are now using the right approach, but the library likely does not parse things after the `.` when the number is in the same as the `beta`. Hopefully this should be solved by doing a RC in a couple of days.
Author
Owner

@kradalby commented on GitHub (Sep 18, 2024):

I think this should be resolved now with the release of 0.23.0, and I'll try to remember to do it properly from here on.

@kradalby commented on GitHub (Sep 18, 2024): I think this should be resolved now with the release of 0.23.0, and I'll try to remember to do it properly from here on.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#700