-
Notifications
You must be signed in to change notification settings - Fork 173
Fix error message for older template version registration #4699
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
base: main
Are you sure you want to change the base?
Conversation
|
@copilot you haven't committed anything. |
|
@copilot nothing is commited. |
Unit Test Results658 tests 658 ✅ 6s ⏱️ Results for commit a5c273a. ♻️ This comment has been updated with latest results. |
|
This PR adds a semantic version comparison to prevent attempts to upload an older version of a bundle when a newer one exists and display a more relevant error message |
|
You can test the semver comparison with the below script. |
|
I'm a little concerned about putting complex code into bash scripts. It feels like this bug (which, as mentioned in the issue, is low priority) could be addressed by changing the text from...
...to...
(or some other message that better explains the reasons why this failure might have happened). ... rather than adding this semver code into the script. My suggestion is that we either close the issue as "won't fix" or take the easier-to-maintain path of simply updating the error message. |
|
@martinpeck the problem is that the existing behaviour of the current comparison does not work for less than because it is only checking for equality so it attempts to push older versions and then the api doesn't give an easily understandable error, there are other ways to achieve the semver comparison but they rely on tools being available on the OS. |
|
Ah, right...so it's the API that's giving the wrong/unclear error? So, if the API returned a better error ("Template with this version, or newer, already exists") would that also fix things? |
|
Yes, the API returns 409 Conflict: "A template with this version already exists" however when versions are equal the API request is never made, so it's also inconsistent behaviour between the two scenarios. |
|
Maybe just best to rely on the API? |
|
If the error message from the API was more accurate then that would be fine |
|
I suggest we do that. Maybe ask copilot. |
|
since we run in a devcontainer there are one liners in linux like the sort command that would remove the bash complexity, I can give those a try and see and also look at the api |
|
Hi @martinpeck @marrobi |
marrobi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
/test 68af3f0 |
|
🤖 pr-bot 🤖
(in response to this comment from @marrobi) |
When trying to register an older bundle version you get a 409 "A template with this version already exists" error instead of a more accurate message like "A newer version of this template already exists. (existing: 1.2.6, attempted: 1.2.1) Registration aborted." the error should actually come from register_bundle_with_api.sh instead of the API.
So if you (incorrectly try to register an older version of an existing template it should fail before sending the register api request.
To Fix:
The logic in function get_template devops/scripts/register_bundle_with_api.sh should check if the version is the same or older and exit with code 1 and a useful error so it errors at that stage instead of continuing the request.
The message for the 409 error could also be updated to reflect that the version could differ.
The existing code only checks equal versions but not less than.
`if [[ "$(echo "$get_result" | jq -r .version)" == "$template_version" ]]; then
Fixes #4685