Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,8 @@ public DataStore getImageStore(String storeUuid, Long zoneId, VolumeVO volume) {
}

if (imageStore == null) {
throw new CloudRuntimeException(String.format("Cannot find an image store for zone [%s].", zoneId));
logger.error("Cannot find an image store for zone [{}].", zoneId);
throw new CloudRuntimeException("Failed to create template. Please contact the cloud administrator.");
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getImageStore is used for both template creation and volume upload (e.g., VolumeApiServiceImpl.uploadVolume calls _tmpltMgr.getImageStore(...)). Throwing "Failed to create template..." here will surface an incorrect error message to volume-upload callers. Consider using an operation-neutral message (e.g., "Failed to find an image store. Please contact the cloud administrator."), or passing a caller-specific context string into getImageStore so each API reports the right high-level failure without exposing the zone ID.

Suggested change
throw new CloudRuntimeException("Failed to create template. Please contact the cloud administrator.");
throw new CloudRuntimeException("Failed to find an image store. Please contact the cloud administrator.");

Copilot uses AI. Check for mistakes.
Comment on lines +479 to +480
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are existing unit tests for getImageStore in TemplateManagerImplTest, but they currently only assert that an exception is thrown. Since this change is specifically about preventing infrastructure/zone ID leakage via exception messages, please add assertions that the thrown CloudRuntimeException message does not include the zone ID (and matches the new sanitized message).

Copilot uses AI. Check for mistakes.
}

return imageStore;
Expand Down Expand Up @@ -1702,7 +1703,8 @@ public VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command) t
}
DataStore store = _dataStoreMgr.getImageStoreWithFreeCapacity(zoneId);
if (store == null) {
throw new CloudRuntimeException("cannot find an image store for zone " + zoneId);
logger.error("Cannot find an image store for zone [{}].", zoneId);
throw new CloudRuntimeException("Failed to create template. Please contact the cloud administrator.");
Comment on lines 1705 to +1707
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same log+throw pattern and user-facing message is now duplicated here and in getImageStore. To avoid the two sites drifting (especially if you later tweak the sanitized message), consider factoring this into a small helper (e.g., throwImageStoreNotFound(zoneId, operation)), which logs the detailed message and throws the sanitized exception.

Copilot uses AI. Check for mistakes.
}
AsyncCallFuture<TemplateApiResult> future = null;

Expand Down
Loading