Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ConvertTo-Json detect circular references #6638

Closed
mtman opened this issue Apr 12, 2018 · 6 comments
Closed

Make ConvertTo-Json detect circular references #6638

mtman opened this issue Apr 12, 2018 · 6 comments
Assignees
Labels
Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif Resolution-No Activity Issue has had no activity for 6 months or more WG-Cmdlets-Utility cmdlets in the Microsoft.PowerShell.Utility module

Comments

@mtman
Copy link

mtman commented Apr 12, 2018

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.
@iSazonov iSazonov added Issue-Enhancement the issue is more of a feature request than a bug WG-Cmdlets-Utility cmdlets in the Microsoft.PowerShell.Utility module labels Apr 13, 2018
@iSazonov
Copy link
Collaborator

iSazonov commented Apr 13, 2018

Default values is

        private int _depth = 2;
        private const int maxDepthAllowed = 100;

Is maxDepthAllowed value good protection?

@iSazonov iSazonov added Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif and removed Issue-Enhancement the issue is more of a feature request than a bug labels Apr 13, 2018
@iSazonov
Copy link
Collaborator

.Net Core 3.1 and later support this. I hope we will resolve issue after moving to .Net Core 5.0.
For reference #11198.

@iSazonov iSazonov self-assigned this Feb 15, 2020
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

1 similar comment
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-No Activity Issue has had no activity for 6 months or more labels Nov 16, 2023
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

Copy link
Contributor

This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif Resolution-No Activity Issue has had no activity for 6 months or more WG-Cmdlets-Utility cmdlets in the Microsoft.PowerShell.Utility module
Projects
None yet
Development

No branches or pull requests

2 participants