DynamicsNinja / FlowExecutionHistory

XrmToolBox tool that allows you to browse Power Automate flow runs by applying multiple filters including multiple flows at the same time.
MIT License
9 stars 0 forks source link

Error when using MFA and Connect to Power Automate API for Failures #26

Closed alex-mcla closed 5 months ago

alex-mcla commented 5 months ago

Hi Ivan

Thanks very much for the latest version. I was able to use it to get 5 failed flow runs for today so far, but when I extended to include all failures from 1st April, I got the error below. I was able to get all successful executions from the 1st (after restarting the tool):


System.NullReferenceException:
Object reference not set to an instance of an object.
Flow Execution History
- Fic.XTB.FlowExecutionHistory.Services.FlowClient.<>c__DisplayClass19_0.<GetFlowRunsFromCache>b__0(FlowRunsCache x)
- System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
- Fic.XTB.FlowExecutionHistory.Services.FlowClient.GetFlowRunsFromCache(String flowId, String status, DateTimeOffset dateFrom)
- Fic.XTB.FlowExecutionHistory.Services.FlowClient.GetFlowRuns(Flow flow, String status, DateTimeOffset dateFrom, DateTimeOffset dateTo, Int32 durationThreshold, Boolean includeTriggerOutputs)
- Fic.XTB.FlowExecutionHistory.FlowExecutionHistory.<>c__DisplayClass26_0.<GetFlowRuns>b__3(Flow f)
- System.Threading.Tasks.Parallel.<>c__DisplayClass17_0`1.<ForWorker>b__1()
- System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
- System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object <p0>)

DynamicsNinja commented 5 months ago

It's hard to find the issue when I can't reproduce the bug :( I did some additional checks, can you please try with the latest version?

alex-mcla commented 5 months ago

I really appreciate your efforts on this Ivan! I'll keep an eye on my emails. I now get:

Error Time: 2024-04-03 12:46:18.295 Newtonsoft.Json.JsonSerializationException Error converting value "The request failed. Error code: 'InvalidApprovalCreateRequestAssignedToNoValidUsers'. Error Message: 'Required field 'assignedTo' contained no valid users in the organization'." to type 'Fic.XTB.FlowExecutionHistory.Models.DTOs.Operationoutputs'. Path 'operationOutputs', line 1, position 1354. Newtonsoft.Json at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at Fic.XTB.FlowExecutionHistory.Services.FlowClient.GetFlowRunErrorDetails(FlowRun flowRun) at Fic.XTB.FlowExecutionHistory.Services.FlowClient.<>cDisplayClass17_0.b0(FlowRun fr) at System.Threading.Tasks.Parallel.<>cDisplayClass17_0`1.b1() at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask) at System.Threading.Tasks.Task.<>c__DisplayClass176_0.b__0(Object )

DynamicsNinja commented 5 months ago

This is a different error, seems like Microsoft changed the JSON response for the run errors. In one case operationOutputs property from JSON is an object with 2 properties and in another case, it's just a string.

Need to think about how to parse those kinds of responses.

alex-mcla commented 5 months ago

Thanks for the update. Does that mean the errors will occur regardless of the authentication method?

Let me know when you'd like me to re-test.

DynamicsNinja commented 5 months ago

Now you should get no error from the tool, but maybe some error messages for flow runs will now lack error details in the popup.

alex-mcla commented 5 months ago

All working now! Many thanks again for the fixes.