Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not return hard error on unparsable version in HTTP proto #975

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions conn_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,7 @@ func (h *httpConnect) readVersion(ctx context.Context) (proto.Version, error) {
for rows.Next() {
var v string
rows.Scan(&v)
version, err := proto.ParseVersion(v)
if err != nil {
return proto.Version{}, err
}
version := proto.ParseVersion(v)
return version, nil
}
return proto.Version{}, errors.New("unable to determine version")
Expand Down
13 changes: 7 additions & 6 deletions lib/proto/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,22 @@ type Version struct {
Patch uint64
}

func ParseVersion(v string) (ver Version, err error) {
func ParseVersion(v string) (ver Version) {
var err error
parts := strings.Split(v, ".")
if len(parts) < 3 {
return Version{}, fmt.Errorf("%s is not a valid version", v)
return ver
}
if ver.Major, err = strconv.ParseUint(parts[0], 10, 8); err != nil {
return Version{}, err
return ver
}
if ver.Minor, err = strconv.ParseUint(parts[1], 10, 8); err != nil {
return Version{}, err
return ver
}
if ver.Patch, err = strconv.ParseUint(parts[2], 10, 8); err != nil {
return Version{}, err
return ver
}
return ver, nil
return ver
}

func CheckMinVersion(constraint Version, version Version) bool {
Expand Down