question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`maxDepth` on `jsonValue` not working

See original GitHub issue

I’m running v 2.23.0

When running this:

fc.assert(
    fc.property(fc.json({maxDepth: 10, depthFactor: 100}), (json) => {
        console.log(json);
        testPoolifyUnpoolify(json as JsonValue);
    }),
    {verbose: true, seed: 1},
);

I always get this output no matter what maxDepth or depthFactor is. Same when I use fc.jsonValue or fc.jsonObject(different output, but same thing, the output is the same)

When I leave out seed, I get different outputs everytime, but the maxDepth of the object never changes (even when I set maxDepth and depthFactor to 1000

[1.1605637550189104e+65,-1.8423363825974171e-155]
[null,null]
false
"zi"
["jx<gAFMtP",null,false,"*-evzweV-*",-2.9e-322]
{"*+s)%%":-3.0615445798526363e-137,">}D5Pk<=(":true,"":-8.916095377805842e-269,"<_":false}
{"Rc>gV%j&N~":true,"$$\"#$  / ":null,"":null,"#":null,"x]@I":null}
-4.1525241057849684e-106
null
["ei#5F3"]
[null,null,null,null,null]
false
[null]
"5N| G@VQ.."
{"":true,"D\\d.d":false,"&'":true,"+l3 )<$*":-2.85409194801039e-191,"zAtfZ&":"hQln"}
[-1.0653066974430237e+248,9.454767484148118e+268,-1.7653965860088798e-214,-3.607621003530778e-129,-4.852957352547658e-136]
["?E:cR",false,"c4}-hv%yW",false,-2.238093053332995e-192]
null
[false,true]
{"5y":null,"y":null}
true
[null,-8.4137512129510665e+245,"<h|xw"]
[true,-3.6772501579408783e-138,false]
[null]
false
{"vM{^^":" ImdH","2fx*":-1.6e-322,"":-1.7976931348623143e+308,"qHH6Gk":7.157927070759342e+43,"@Y0xs":null}
{}
{"e*f&z<4":7.037047740509628e-132}
[")+~","zd&q%","ALFk\\#c*KV"]
["rC","Gq)`('Hs_",3.025804617711035e+178,"k&n",true]
1.7976931348623113e+308
null
{"X)j":2.1629205585163314e-231,"N{o4a ":"yB:","u/9`":null,"{0":-1.9217347146390265e+113,"oFf*Gus":null}
"}"
[false,true,true,true]
true
["|u%a}8!z0#","{K","q"]
[]
false
{}
null
null
[true,false]
-3.603629137412196e-265
{"_zK":null,"AIo<4$:A":"SFq^+i7","#%&9eK!wO":false}
true
["5@#n0|","O1$",""]
{"":-2.9782890422455327e+255," j!0":-1.0479956480311591e-162,"fH(.a":2.758176663043067e+92,"}(jKG":-1.902033828458498e-126,"8w'E":1.2732807500211005e+179}
{"#|eA|9}h!>":true}
"$-(F)"
3e-323
[-1.8746904761410538e-298]
false
[null,null,null,null,null]
[".T%wwfpg:y"]
[null]
{"Nf&5":2.8873533988267525e-170,"":true,"Xc\"":null,"_ >vSeh":"*G?","=OawKi7":null}
[]
{"OC[MOJw%":null}
"ges(dk("
{">Eg&Gdv\"":2.2881157822979433e+226,"{]>Pj":133020.52617428786,"`knOi{ ":1.2632862668499098e-71,"":5.3318996347400214e+72}
-3.411537840694293e-11
"`^O7pV"
"ttx;X@N"
3.0691830158402806e-155
{"%*EH{. -":true}
[null,null]
1.1454945138091173e-46
null
true
{"\"":"leM r~*"}
{"~!D@L@gR":"le","0yO":")?&|Rl","FNsb~*\\7;N":"1{\\+Zi"}
null
["w<-%Ra"]
[]
-3.098772027733863e-58
{}
[]
false
null
null
["+Mb^[OOwf"]
{"bk":-4.0175676216709717e-243,"z`F2":-7.159008907172276e+93,"":null,"w0fr\",":null,"2KcAl=":null}
[false,true,true,true,false]
"5f"
true
[" jRS[B","8@{Y@Q0AV#","|+B"]
false
{"a{":"A\\/hhKc","FwmbjTo]1>":")N%"}
-1.5e-323
[]
null
"t~h"
true
{"v":true,"n&E@9XQqS":true,"":true}
"b_#=E$N\\a"
{"WJ!":-2.646684589725734e-273,"ls1}`c":"t'iT2b}2","#xOVY<+\"":null,"":null}
{"Jv0WdIGF":" )!3\\lT","!/Yms:":"`jx.X","":"nz","h}t":"#","<":"u^"}
{"q(;=:a)":7.423270140880227e+284,"!":"[WWg?","uU<n":null,"":"y3"}
["ur","U[1&#$SSC_","qjc4Y6Z","y=","UZ>% "]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
dubzzzcommented, Mar 16, 2022

MaxDepth and depthFactor seems to hit an asymptote when I increase the former and decrease the latter- is this a known issue? https://runkit.com/stevenqzhang/fast-check-maxdepth-testing

This is a known issue due to:

  • 33% chance to have basic values
  • 33% chance to have arrays with half of them with basic values
  • 33% chance to have objects with half of them with basic values

Which is definitely something that must change. But not sure I can really change such thing in a minot release as it would have potential terrible impacts on some existing test suites on user side. But there is definitely something to do for v3 (coming soon).

depthFactor? — default: 0 — factor to change the probability to generate leaf values as we go deeper in the structure, numeric value >=0 (eg.: 0.1). The closer the number is to 0, the higher the probability of generating leaf values

Definitely, like it. Feel free to open a PR with the suggested update. By the way, there probably other references to this depthFactor in the md file, they can all be adapted with the same idea.

0reactions
dubzzzcommented, May 10, 2022

Closing the issue as there is no activity on it. Feel free to re-open it or open another one referencing this one if you believe there is still something to check.

Read more comments on GitHub >

github_iconTop Results From Across the Web

iphone - parsing json - reached max depth - Stack Overflow
I get this error message: -JSONValue failed. Error is: Input depth exceeds max depth of 32 Changing the depth to a higher number...
Read more >
MaxDepth setting - Json.NET
This sample uses the P:Newtonsoft.Json.JsonSerializerSettings.MaxDepth setting to constrain JSON to a maximum depth when deserializing.
Read more >
The JSON value of length n is too large and not supported #2
I'm referring to this issue #30746 that was closed with limit of 125MB staying fixed opposed to being configurable.
Read more >
std.json - D Programming Language
JSONException if string does not follow the JSON grammar or the depth exceeds the max depth, ConvException if a number in the input...
Read more >
Migrate from Newtonsoft.Json to System.Text.Json - .NET
Not supported, but workaround is possible. The workarounds are custom converters, which may not provide complete parity with Newtonsoft.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found