-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Make ConvertTo-Json detect circular references #6638
Copy link
Copy link
Closed
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Metadata
Metadata
Assignees
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
The current way to deal with circular references is the
Depthparameter. Its default value is too low and increasing it doesn't address a usual use case where the object is deep and doesn't contain any circular reference.Add a
CircularDetectionswitch parameter.Once a circular reference is detected, throw an exception. If the switch is not present, cap the object by the depth limit.
Currently no exception is thrown when the depth limit is reached. This easily propagates the error and may remain undetected until the collected data is evaluated. One option to consider is to make the detection default. The switch can be changed to
-DisableCircularDetectionwhich enables the current behavior. This is a breaking change for some users.Unaffected groups of users:
Depthparameter.Affected groups of users: