Skip to content

Commit 444f25e

Browse files
committed
Improve empty scheduleActions check
1 parent 629c6dc commit 444f25e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/IntuneCD/update/Intune/DeviceCompliance.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,21 @@ def main(self) -> dict[str, any]:
172172
for rule in repo_data.get("scheduledActionsForRule"):
173173
self._get_notification_template_id(rule)
174174

175-
for item in intune_data["value"]:
176-
if item["scheduledActionsForRule"]:
177-
for action in item["scheduledActionsForRule"][0][
178-
"scheduledActionConfigurations"
179-
]:
180-
self.remove_keys(action)
175+
for item in intune_data.get(
176+
"value", []
177+
): # Ensure "value" exists and is iterable
178+
actions = item.get("scheduledActionsForRule", [])
179+
180+
if actions: # Ensure actions is not None and not empty
181+
first_action = actions[0].get(
182+
"scheduledActionConfigurations", []
183+
)
184+
185+
if (
186+
first_action
187+
): # Ensure scheduledActionConfigurations is not None
188+
for action in first_action:
189+
self.remove_keys(action)
181190

182191
try:
183192
self.process_update(

0 commit comments

Comments
 (0)