Skip to content

Make ConvertTo-Json detect circular references #6638

@mtman

Description

@mtman

The current way to deal with circular references is the Depth parameter. 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 CircularDetection switch 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 -DisableCircularDetection which enables the current behavior. This is a breaking change for some users.

Unaffected groups of users:

  • Those who use the Depth parameter.
  • Those who use shallow objects falling bellow the depth limit.
  • Those who use deep objects without circular references, but are not aware of or affected by the silent error.

Affected groups of users:

  • Those who use objects with circular references while the very low depth limit doesn't affect them.

Metadata

Metadata

Assignees

Labels

Issue-Discussionthe 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 moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions