Skip to content

Conversation

Copy link

Copilot AI commented Jan 1, 2026

The Audit Log Wizard's "Start Audit Log subscription" flow fails when the child flow (AdminAuditLogsOffice365ManagementAPISubscription) returns error responses. The Parse_JSON action attempts to parse @body('Run_a_Child_Flow')?['response'], which contains the string "Failed" on error, causing: Unexpected character encountered while parsing value: F. Path '', line 0, position 0.

Changes

  • Replaced direct Parse_JSON with conditional validation in AuditLogWizardStartAuditLogsubscription
  • Added "Configure Run After" to handle both Succeeded and Failed states from child flow
  • Implemented dual-path response handling:
    • Valid JSON responses → parse and extract error details
    • Text responses (e.g., "Failed") → pass through directly without parsing

Implementation

{
  "Check_child_flow_response": {
    "runAfter": {
      "Run_a_Child_Flow": ["Succeeded", "Failed"]
    },
    "type": "Condition",
    "expression": {
      "and": [
        {"not": {"equals": ["@body('Run_a_Child_Flow')?['response']", "Failed"]}},
        {"contains": ["@string(body('Run_a_Child_Flow')?['response'])", "{"]}
      ]
    },
    "actions": {
      "Parse_JSON": { /* ... */ },
      "Update_a_row_with_parsed_response": { /* ... */ }
    },
    "else": {
      "actions": {
        "Update_a_row_with_failed_response": { /* ... */ }
      }
    }
  }
}

Both success and error paths now update admin_responsestate correctly without Parse_JSON failures.

Original prompt

This section details on the original issue you should resolve

<issue_title>Audit Log Wizard>Start Audit Log subscription Fails</issue_title>
<issue_description>Action 'Parse_JSON' failed: The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value cannot be parsed: 'Unexpected character encountered while parsing value: F. Path '', line 0, position 0.'.

INPUTs > Content = Failed and not valid JSON.

Image</issue_description>

<agent_instructions>Analyze and troubleshoot the issue with any code fixes other that that provide the solution for this.</agent_instructions>

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

@AmarSaiRam Hi @david-haver02862 ### Root Cause The Parse_JSON action is trying to parse the output from the child flow "Run_a_Child_Flow" (which calls flow ccca4a5c-21e8-ed11-a7c6-0022480813ff), but:

The child flow is returning the text "Failed" instead of valid JSON
The Parse_JSON action expects valid JSON but receives: "Failed" (starting with character 'F')
This causes the error: "Unexpected character encountered while parsing value: F. Path '', line 0, position 0."

Solution

You need to fix this issue by addressing the child flow or modifying the parent flow to handle non-JSON responses:

Option 1: Fix the Child Flow (Recommended)
The child flow "Admin | Audit Logs | Office 365 Management API Subscription" needs to be investigated:

Check if the Office 365 Management API connection is properly configured

Ensure the HTTP connector or Office 365 Management API connector has valid credentials
Verify the service principal or connection has the necessary permissions
Review the child flow's error handling

The child flow should return a proper JSON response even on failure
Example successful response: {"status": "success", "message": "Subscription started"}
Example error response: {"status": "error", "message": "Failed to start subscription"}
Option 2: Modify the Parent Flow to Handle Errors
Add error handling before the Parse_JSON action:

Add a Condition to check if the response is valid JSON before parsing:

Code
Condition: @contains(string(outputs('Run_a_Child_Flow')?['body']), '{')
Add a Compose action to handle the "Failed" response:

If TRUE (valid JSON): Continue to Parse_JSON
If FALSE (text like "Failed"): Create a JSON object manually:
JSON
{
"error": {
"message": "@{outputs('Run_a_Child_Flow')?['body']}"
}
}
Option 3: Add Configure Run After on Parse_JSON
Configure the Parse_JSON action to handle failures:

Add another branch after Run_a_Child_Flow
Configure it to run on "has failed" or "has timed out"
Handle the error case explicitly</comment_new>

Custom agent used: CoE Custom Agent
Specialized agent for triaging and fixing issues in the CoE Starter Kit. Always consult the official CoE docs and the team’s SharePoint notes first, then mine prior GitHub issues and the CoE Common Responses playbook.


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

…from child flow

Co-authored-by: AmarSaiRam <220305901+AmarSaiRam@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix audit log subscription failure by correcting JSON parsing Fix Parse_JSON error in Audit Log Wizard when child flow returns "Failed" Jan 1, 2026
Copilot AI requested a review from AmarSaiRam January 1, 2026 05:10
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.

Audit Log Wizard>Start Audit Log subscription Fails

2 participants