microsoft / Power-Fx

Power Fx low-code programming language
MIT License
3.18k stars 321 forks source link

InvalidOperationException when setting variable to value that cannot be copied. #2226

Open coletaylor1 opened 7 months ago

coletaylor1 commented 7 months ago

We log the below expression and then see an InvalidOperationException thrown. The card does have two Dataverse tables attach so I suspect they try to assign these to variables. Still, we set a flag to not break this at runtime and if it's a user error, I believe check should fail right or a proper exception should be thrown.

PowerFxExpressionEvaluator Check success with the expression: #$fne$#

System.InvalidOperationException: Can't set 'varUsers' to a table value that cannot be copied.
   at Microsoft.PowerFx.RecalcEngine.UpdateVariable(String name, FormulaValue value)
   at Microsoft.PowerCards.Scripting.PowerFxExpressionEvaluator.UpdateVariable(String name, FormulaValue value) in C:\__w\1\s\src\PowerCards\Microsoft.PowerCards.Scripting\PowerFxExpressionEvaluator.cs:line 177
   at Microsoft.PowerCards.Scripting.PowerFxExpressionEvaluator.SetEngineContext() in C:\__w\1\s\src\PowerCards\Microsoft.PowerCards.Scripting\PowerFxExpressionEvaluator.cs:line 129
   at Microsoft.PowerCards.Scripting.PowerFxExpressionEvaluator.EvalAsync() in C:\__w\1\s\src\PowerCards\Microsoft.PowerCards.Scripting\PowerFxExpressionEvaluator.cs:line 76
   at Microsoft.PowerCards.Scripting.PowerFxRecalcEngine.EvalAsync(List`1 memoryContexts, String expressionText, CancellationToken cancel, CultureInfo culture, ILoggerFactory loggerFactory, PowerFxContext powerFxContext) in C:\__w\1\s\src\PowerCards\Microsoft.PowerCards.Scripting\PowerFxRecalcEngine.cs:line 53
   at Microsoft.PowerCards.Scripting.PowerFxScriptRunner.RunScriptAsync(Object memory, String script, CancellationToken cancellationToken) in C:\__w\1\s\src\PowerCards\Microsoft.PowerCards.Scripting\PowerFxScriptRunner.cs:line 142
MikeStall commented 7 months ago

to reiterate: the issue here is that we should have caught this at compile time in Check() and never gotten to the point of having a runtime exception. I'm guessing it's an expression like Set(Accounts, Accounts)