Set client version to lowest for compat if server version can't be recognized #612

Merged
6543 merged 5 commits from jolheiser/go-sdk:low-version into main 2023-04-02 21:30:54 +00:00

This is a possible resolution for gitea/tea#531

This is a possible resolution for gitea/tea#531
jolheiser added this to the v0.16.0 milestone 2023-02-09 04:09:25 +00:00
jolheiser added 1 commit 2023-02-09 04:09:26 +00:00
continuous-integration/drone/pr Build is failing Details
5c97d1793c
fix: default version to lowest for compat
Signed-off-by: jolheiser <john.olheiser@gmail.com>
lunny approved these changes 2023-02-09 06:06:09 +00:00
drsybren reviewed 2023-02-10 10:13:33 +00:00
gitea/version.go Outdated
@ -100,0 +101,4 @@
if strings.TrimSpace(raw) != "" {
// Version was something, just not recognized
// Default to lowest version for safety
c.serverVersion = version1_11_0

IMO, this should not happen silently. If users are not aware that the server version wasn't recognised, and that a limited feature set is available, they could get properly confused. And it'll be hard to actually find that this is the root cause.

IMO, this should not happen silently. If users are not aware that the server version wasn't recognised, and that a limited feature set is available, they could get properly confused. And it'll be hard to actually find that this is the root cause.
Poster
Owner

Good point, I can add some output to let the user know.

Good point, I can add some output to let the user know.

I would let the programms using the sdk handle this ... they can decide what to do with that error

we should just declair an err that errors.Is could check and if the program want to have some "just use it with this or that version" ... like you propose, there is a clientOption already for it ...

I would let the programms using the sdk handle this ... they can decide what to do with that error we should just declair an err that `errors.Is` could check and if the program want to have some "just use it with this or that version" ... like you propose, there is a clientOption already for it ...
Poster
Owner

@6543
In relation to tea then, do you think we should add a flag (or similar) to "set/force" a version?

Using the raw SDK, people can set it, but afaik tea doesn't have a way for users to set it should an error occur.

Apologies, this is slightly off-topic for this PR, but I want to make sure we put the fix(es) in the right place.

@6543 In relation to `tea` then, do you think we should add a flag (or similar) to "set/force" a version? Using the raw SDK, people can set it, but afaik `tea` doesn't have a way for users to set it should an error occur. Apologies, this is slightly off-topic for this PR, but I want to make sure we put the fix(es) in the right place.

What if we (as @jolheiser said) have a "set/force" version, but as for this fallback we return an err that says "hey we weren't able to determine a version so we set it as 1.xyz" so a user can parse the error, and see oh its error x and I can handle that/report it to user, but it won't prevent the program from calling additional calls.

What if we (as @jolheiser said) have a "set/force" version, but as for this fallback we return an err that says "hey we weren't able to determine a version so we set it as 1.xyz" so a user can parse the error, and see oh its error x and I can handle that/report it to user, but it won't prevent the program from calling additional calls.
6543 requested changes 2023-02-15 22:53:45 +00:00
6543 left a comment
Owner

as per comment

as per comment
jolheiser added 2 commits 2023-03-23 03:32:30 +00:00
4ddde42858
review: return error for compat
Signed-off-by: jolheiser <john.olheiser@gmail.com>
continuous-integration/drone/pr Build is failing Details
224a410533
review: return client if unknown version error
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Poster
Owner

@6543 I've updated to return a special error that can be checked via errors.As which holds the raw version given back from the server, but also returns the client set to 1.11.0. The user can then decide how best to move forward.


Regarding tea, we can either add a --force-version (or something shorter) flag to force a version, or we can just check for this new error and print it out to the user, but allow them to continue using it in the meantime.

But perhaps that's better discussed in an issue on the tea repo.

@6543 I've updated to return a special error that can be checked via `errors.As` which holds the raw version given back from the server, but also returns the client set to `1.11.0`. The user can then decide how best to move forward. --- Regarding `tea`, we can either add a `--force-version` (or something shorter) flag to force a version, or we can just check for this new error and print it out to the user, but allow them to continue using it in the meantime. But perhaps that's better discussed in an issue on the `tea` repo.
jolheiser added 1 commit 2023-03-28 21:21:52 +00:00
continuous-integration/drone/pr Build is failing Details
eb07a10707
chore: goimports
6543 approved these changes 2023-04-02 21:04:54 +00:00

@jolheiser can not update base-branch :D might enable maintainer edit

@jolheiser can not update base-branch :D might enable maintainer edit
jolheiser added 1 commit 2023-04-02 21:06:35 +00:00
continuous-integration/drone/pr Build is passing Details
bcb489a5a6
Merge branch 'main' into low-version
Poster
Owner

Updated and enabled in case it's needed.

Updated and enabled in case it's needed.
6543 merged commit 7511c6d3cd into main 2023-04-02 21:30:54 +00:00
6543 added the
kind/feature
label 2023-04-03 03:31:49 +00:00
Sign in to join this conversation.
There is no content yet.