Skip to content

Fix null reference in table formatting#3021

Open
gregli-msft wants to merge 2 commits intomainfrom
gregli/repl-table-format-blank
Open

Fix null reference in table formatting#3021
gregli-msft wants to merge 2 commits intomainfrom
gregli/repl-table-format-blank

Conversation

@gregli-msft
Copy link
Contributor

Without this change:

  • With table formatting on, it is hard to distinguish a blank record from a blank field in a table. In the example below, a blank record is represented by a Blank() which could be confused for the value of the first column (which shows an empty space for Blank() which could be confusing).
  • With table formatting off, it encounters a null reference exception.
>> Table(Blank(),{a:Blank(),b:true},Blank(),{a:42,b:Blank()})

  a    b
 ==== ======
 Blank()
       true
 Blank()
  42

>> Option( Options.FormatTable, false )
false

>> Table(Blank(),{a:Blank(),b:true},Blank(),{a:42,b:Blank()})
Unhandled exception. System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.PowerFx.Repl.Services.StandardFormatter.TryGetSpecialFieldNames(RecordValue record) in D:\repos\pfx-udt-decimal\src\libraries\Microsoft.PowerFx.Repl\Services\StandardFormatter.cs:line 100
   at Microsoft.PowerFx.Repl.Services.StandardFormatter.FormatRecordCore(RecordValue record) in D:\repos\pfx-udt-decimal\src\libraries\Microsoft.PowerFx.Repl\Services\StandardFormatter.cs:line 37
   at Microsoft.PowerFx.Repl.Services.StandardFormatter.FormatStandardTable(TableValue table, HashSet`1 selectedFieldNames) in D:\repos\pfx-udt-decimal\src\libraries\Microsoft.PowerFx.Repl\Services\StandardFormatter.cs:line 294
...

After this change:

>> Table(Blank(),{a:Blank(),b:true},Blank(),{a:42,b:Blank()})

  a    b
 ==== ======
 <blank record>
       true
 <blank record>
  42

>> Option( Options.FormatTable, false )
false

>> Table(Blank(),{a:Blank(),b:true},Blank(),{a:42,b:Blank()})
[Blank(), {a:Blank(), b:true}, Blank(), {a:42, b:Blank()}]

@gregli-msft gregli-msft requested a review from a team as a code owner February 9, 2026 07:13
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.

1 participant