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 (possibly just for Failures) #25

Closed alex-mcla closed 5 months ago

alex-mcla commented 5 months ago

Started the tool already connected to the environment using MFA. All defaults left as is.

Then connected to the API.

Selected Status Failed. Deselected Draft. Selected all Flows.

The tool worked for a couple of seconds and then gave the following error:


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

I had a similar issue when I connected to a tenant as a guest user. I couldn't find out what was the issue with guest users and I ended up using client and secret in those environments.

alex-mcla commented 5 months ago

It had been working from when you added the connect to API button until a few days ago. I wasn't sure whether it was something you were working on, so only created the ticket today. The client isn't wanting to share the client secret with us. My user permissions haven't changed as far as I'm aware. I have full Sys Admin Dataverse access, but I realise this isn't the same as the API. Is there anything I can do to investigate further?

alex-mcla commented 5 months ago

I've just tried again looking for failures in the last hour and got a different error (see below). Is there a possibility this is an error associated with the latest version of the tool?

I then narrowed the time window - to get all flow runs from 16:00-16:08 and it succeeded.

I was able to widen the all flow runs until I was getting several hundred successes and a few cancelled.

But when I tried again for failures only, it worked whilst there were no failures, and then reported the error I'm assuming as soon as the first error run was encountered.

Error details were:

Error Time: 2024-03-28 16:01:51.702 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

I think I found out where is the issue. Will publish the fixed version.