CAM: gracefully handle tool numbers that are strings in the tool library JSON

This commit is contained in:
Samuel Abels
2025-06-29 21:39:04 +02:00
parent da8eec5744
commit 2d1746d04f

View File

@@ -81,7 +81,11 @@ class FCTLSerializer(AssetSerializer):
tools_list = data_dict.get("tools", [])
for tool_data in tools_list:
tool_no = tool_data["nr"]
try:
tool_no = int(tool_data["nr"])
except ValueError:
Path.Log.warning(f"Invalid tool ID in tool data: {tool_data}. Skipping.")
continue
tool_id = pathlib.Path(tool_data["path"]).stem # Extract tool ID
tool_uri = AssetUri(f"toolbit://{tool_id}")
tool = dependencies.get(tool_uri)