Skip to content

Inconsistent version requirements in lib/build and lib/upgrade #9267

Closed

Description

@gudvinr

Does your log mention database corruption?

No

Include required information

  • syncthing v1.27.0@6069cf3

Preamble

semver lists following versions as correct:

<valid semver> ::= <version core>
                 | <version core> "-" <pre-release>
                 | <version core> "+" <build>
                 | <version core> "-" <pre-release> "+" <build>

So, v1.27.0, v1.27.0-abc.1, v1.27.0-abc.1+xyz, v1.27.0+xyz all are valid semver strings.

lib/build

lib/build contains allowedVersionExp:

allowedVersionExp = regexp.MustCompile(`^v\d+\.\d+\.\d+(-[a-z0-9]+)*(\.\d+)*(\+\d+-g[0-9a-f]+)?(-[^\s]+)?$`)

It allows v1.27.0-abc.1+xyz but not v1.27.0+xyz, thus if you built an app with that version (which is permitted by build.go) it won't start

lib/upgrade

lib/upgrade uses CompareVersions to check for upgrade and TestCompareVersions uses 1.0.0+45 as test case

versionParts (that is used inside) correctly parses both v1.27.0-abc.1+xyz and v1.27.0+xyz yielding [1, 27, 0] [abc, 1] and [1, 27, 0] respectively.

Solution

  1. I suggest making versions in form of <version core> "+" <build> valid in lib/build because the both valid semver and already accepted by lib/upgrade and build.go
  2. Check version argument in build.go to avoid building binaries that can't be launched anyway

Activity

  1. added
    bug
    needs-triage
    on Dec 6, 2023
  2. calmh commented on Dec 6, 2023

    @calmh
    Member

    Wo don't generate version numbers with pluses in them as far as I know?

  3. gudvinr commented on Dec 6, 2023

    @gudvinr
    ContributorAuthor

    I generate syncthing builds with specific configurations.
    To differentiate them from vanilla builds right now I use e.g. vX.Y.Z-noupgrade which is technically incorrect semver because noupgrade is not a part of the version but rather "build meta information".

    Difference is that meta is not included in version checks and pre-release part is.

  4. added
    build
    and removed
    bug
    needs-triage
    on Dec 13, 2023
  5. added a commit that references this issue on Jan 2, 2024
  6. added a commit that references this issue on Jan 2, 2024
    fc1c7a3
  7. gudvinr commented on Jan 2, 2024

    @gudvinr
    ContributorAuthor

    @KeyWeeUsr, thanks. Much appreciated.

  8. added 2 commits that reference this issue on Jan 4, 2024
    db2c610
    cbead14
  9. added this to the v1.27.3 milestone on Jan 4, 2024
  10. added a commit that references this issue on Jan 14, 2024
    b2ba185
  11. added 2 commits that reference this issue on Feb 9, 2024
    1f23298
    c6d865b
  12. added
    frozen-due-to-age
    on Apr 9, 2025
  13. locked and limited conversation to collaborators on Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildfrozen-due-to-age

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions