microsoft / microsoft/Power-Fx

InvalidOperationException when setting variable to value that cannot be copied.

Open
#2,226 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

MS_CARDS
Dominant language
C#
Stars
3.4k
Forks
358
Avg merge
10h 34m
Merged PRs (30d)
3

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Microsoft.PowerCards.Scripting.PowerFxExpressionEvaluator.cs, especially SetEngineContext at line 129 and UpdateVariable at line 177, then follow the call from PowerFxRecalcEngine.cs line 53. Reproduce the expression that assigns the non-copyable table and determine how the check should report this condition instead of surfacing InvalidOperationException from UpdateVariable.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.