Copilot commented on code in PR #12768:
URL: https://github.com/apache/cloudstack/pull/12768#discussion_r2905206316
##########
engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql:
##########
@@ -33,3 +33,6 @@ UPDATE `cloud`.`alert` SET type = 34 WHERE name =
'ALERT.VR.PRIVATE.IFACE.MTU';
-- Update configuration 'kvm.ssh.to.agent' description and is_dynamic fields
UPDATE `cloud`.`configuration` SET description = 'True if the management
server will restart the agent service via SSH into the KVM hosts after or
during maintenance operations', is_dynamic = 1 WHERE name = 'kvm.ssh.to.agent';
+
+-- Set default value for vm_template.type to "USER" and update existing
records with NULL type to "USER"
Review Comment:
The comment says this migration sets a *default value* for
`vm_template.type`, but the SQL only backfills existing `NULL` rows. Either (a)
update the comment to only mention backfilling, or (b) also add an `ALTER
TABLE` to set the column default (and possibly `NOT NULL` if that’s the
intended invariant).
```suggestion
-- Update existing vm_template records with NULL type to "USER"
```
##########
server/src/main/java/com/cloud/template/TemplateManagerImpl.java:
##########
@@ -2426,6 +2426,8 @@ public TemplateType validateTemplateType(BaseCmd cmd,
boolean isAdmin, boolean i
throw new InvalidParameterValueException(String.format("Users
can not register Template with template type %s.", templateType));
} else if (cmd instanceof UpdateTemplateCmd) {
throw new InvalidParameterValueException(String.format("Users
can not update Template to template type %s.", templateType));
+ } else if (cmd instanceof GetUploadParamsForTemplateCmd) {
+ throw new InvalidParameterValueException(String.format("Users
can not upload Template to template type %s.", templateType));
Review Comment:
This error is thrown for `GetUploadParamsForTemplateCmd`, but the message
says the user cannot 'upload Template'. Consider wording it in terms of the
actual action (e.g., 'request upload params' / 'get upload parameters') so API
callers can more easily understand which request is being rejected.
```suggestion
throw new
InvalidParameterValueException(String.format("Users can not request upload
parameters for Template with template type %s.", templateType));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]