mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-09-07 02:25:21 +03:00
feat(templates): safely access settings dict keys
Use dict.get() method to safely access 'image' and 'path' keys in settings dictionary to avoid KeyError exceptions when these keys are missing. This improves error handling and prevents server crashes when creating templates with incomplete settings.
This commit is contained in:
parent
e27ddf2cdf
commit
c05f667f3d
@ -197,7 +197,7 @@ class TemplatesService:
|
||||
|
||||
images_to_add_to_template = []
|
||||
if template_type == "dynamips":
|
||||
if settings["image"]:
|
||||
if settings.get("image"):
|
||||
image = await self._find_image(settings["image"])
|
||||
if image.image_type != "ios":
|
||||
raise ControllerBadRequestError(
|
||||
@ -205,7 +205,7 @@ class TemplatesService:
|
||||
)
|
||||
images_to_add_to_template.append(image)
|
||||
elif template_type == "iou":
|
||||
if settings["path"]:
|
||||
if settings.get("path"):
|
||||
image = await self._find_image(settings["path"])
|
||||
if image.image_type != "iou":
|
||||
raise ControllerBadRequestError(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user