You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to dump data for human review in YAML, but some objects have seemingly endless recursion. A -Depth parameter would help here.
Exception calling "Serialize" with "2" argument(s): "Too much recursion when traversing the object graph"
At C:\Users\my\Documents\WindowsPowerShell\Modules\powershell-yaml\0.4.2\powershell-yaml.psm1:398 char:13
So it took less time for Frodo to take the ring to Mount Doom than it took me to get around to adding a -Depth flag, but would you mind giving this PR a try:
note, the absolute max recursion is 1000. Default recursion is 100. Most yaml won't ever get close to 100 let alone 1000, but I have learned not to doubt human creativity. To be fair, the stable version is limited at 50 as it is, so these values should be fine.
There are self referencing, serializable objects like the Root object in the Get-Item . command you see above. Without a depth limiter, you will consume CPU forever, recursing to infinity. YamlDotNet itself has a limit of 50 by default. We raised that a bit and added the flag to the commandlet to allow a customizable range up to 1000. It is unlikely you will ever need more. If there are more than 1000 levels to a YAML, then YAML is probably the wrong tool for the job.
Activity
Serpen commentedon Mar 16, 2025
+1 for that, even standard thing fails quite quick
gabriel-samfira commentedon Jan 5, 2026
So it took less time for Frodo to take the ring to Mount Doom than it took me to get around to adding a
-Depthflag, but would you mind giving this PR a try:It adds far more than a -Depth flag, but I have no idea when I will have enough time again, so it's a dump of many changes that were requested.
For this use case:
gabriel-samfira commentedon Jan 5, 2026
note, the absolute max recursion is 1000. Default recursion is 100. Most yaml won't ever get close to 100 let alone 1000, but I have learned not to doubt human creativity. To be fair, the stable version is limited at 50 as it is, so these values should be fine.
gabriel-samfira commentedon Jan 5, 2026
The PR was merged. There is now a
-Depthflag forConvertTo-Yamlbeedell-roke commentedon Jan 5, 2026
@gabriel-samfira, is
-Depthalso limited (to 1000)?gabriel-samfira commentedon Jan 5, 2026
yes. The default is 100 (which is higher than the old default), but you can raise it up to 1000 if you need to.
beedell-roke commentedon Jan 5, 2026
gabriel-samfira commentedon Jan 5, 2026
There are self referencing, serializable objects like the
Rootobject in theGet-Item .command you see above. Without a depth limiter, you will consume CPU forever, recursing to infinity.YamlDotNetitself has a limit of 50 by default. We raised that a bit and added the flag to the commandlet to allow a customizable range up to 1000. It is unlikely you will ever need more. If there are more than 1000 levels to a YAML, then YAML is probably the wrong tool for the job.