-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Helper method converting PSObject to string may fail #11797
Copy link
Copy link
Closed
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Milestone
Metadata
Metadata
Assignees
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
This was encountered by a MS Partner team. When calling a cmdlet that outputs lots of objects, the SmartToString() helper throws the exception "InvalidOperationException: Collection was modified after the enumerator was instantiated" as the PSObject is modified before the conversion completes. There is already code to catch an ExtendedTypeSystemException and we could extend that for any exception and just return string.empty. Or alternatively, we could make a copy of the object but that would impact perf.
In the repro, it was explicitly going through the
Format-Listcode, althoughFormat-Tablemay also use this helper.