Skip to content

Fix InvalidTemplate crash in Sync Audit Logs V2 retry loop expressions#10913

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-audit-log-template-error
Draft

Fix InvalidTemplate crash in Sync Audit Logs V2 retry loop expressions#10913
Copilot wants to merge 2 commits intomainfrom
copilot/fix-audit-log-template-error

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

Admin | Audit Logs | Sync Audit Logs (V2) fails with InvalidTemplate when using Graph API (admin_AuditLogsUseGraphAPI = true). The Until retry loop expressions use strict bracket notation outputs('Action')['statusCode'] which throws when statusCode is absent from outputs — this happens when an HTTP action fails before producing an HTTP response (network error, auth token acquisition failure, etc.).

Change

All 4 Until loop termination expressions in AdminAuditLogsSyncAuditLogsV2 updated to use optional chaining + coalesce so a missing statusCode defaults to 0 (retry) instead of throwing:

- "@equals(outputs('AuditLogRecords')['statusCode'], 200)"
+ "@equals(coalesce(outputs('AuditLogRecords')?['statusCode'], 0), 200)"
Loop API path
RetryLogic-AuditLogRecords Graph API (reported)
RetryLogic-StartAuditLogQuery Graph API
RetryLogic-ListAuditLogContent O365 Management API
RetryLogic-GetContentDetails O365 Management API
Original prompt

This section details on the original issue you should resolve

<issue_title>[CoE Starter Kit - BUG] ISSUE TITLE</issue_title>
<issue_description>### Does this bug already exist in our backlog?

  • I have checked and confirm this is a new bug.

Describe the issue

When running the inventory flow (core components) Admin | Audit Logs | Sync Audit Logs (V2) - I am getting the below error -

InvalidTemplate. Unable to process template language expressions for action 'RetryLogic-AuditLogRecords' at line '1' and column '11673': 'The template language expression 'equals(outputs('AuditLogRecords')['statusCode'], 200)' cannot be evaluated because property 'statusCode' cannot be selected. Please see https://aka.ms/logicexpressions for usage details.'.

ActionConditionFailed. The execution of template action 'SetHttpCallFailed-FALSE-2_2' is skipped: the 'runAfter' condition for action 'AuditLogRecords-FAILED' is not satisfied. Expected status values 'Skipped' and actual value 'Succeeded'.

We are using the Graph API instead of Office 365 Management API. Use the Graph API environment Variable is set to Yes.

Image

Expected Behavior

No response

What solution are you experiencing the issue with?

Core

What solution version are you using?

4.50.6

What app or flow are you having the issue with?

Admin | Audit Logs | Sync Audit Logs (V2)

What method are you using to get inventory and telemetry?

Cloud flows

Steps To Reproduce

Run the Admin | Audit Logs | Sync Audit Logs (V2)

Anything else?

No response</issue_description>

<agent_instructions>Please check what could be the possible reasons for this issue</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ssions

Use coalesce with optional chaining for statusCode access to prevent
InvalidTemplate when HTTP action fails without populating statusCode
(e.g. network error, auth token failure before HTTP call completes)

Co-authored-by: muditagarwal2308 <113036606+muditagarwal2308@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix template language error in audit logs sync Fix InvalidTemplate crash in Sync Audit Logs V2 retry loop expressions Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CoE Starter Kit - BUG] ISSUE TITLE

2 participants