Skip to content

Incorrectly attempting to register an older template version generates 409 "A template with this version already exists" #4685

@JC-wk

Description

@JC-wk

Describe the bug
This is a minor bug but it does help with troubleshooting an issue.
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.
if [[ "$(echo "$get_result" | jq -r .version)" == "$template_version" ]]; then
It's a bit more complicated to check semvers so would suggest a function to do that and an additional if statement to check for less than.
Might be an easy one for copilot, note that you need set +e and set -e around a function that doesn't return a 0

Steps to reproduce

  1. downgrade template version
  2. make bundle-register DIR=templates/shared_services/gitea/ BUNDLE_TYPE=shared_service
  3. see 409 error

Azure TRE release version (e.g. v0.14.0 or main):
v0.25.0
Deployed Azure TRE components - click the (i) in the UI:
UI Version:
0.8.15
API Version:
0.24.5

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions