postman-app-support icon indicating copy to clipboard operation
postman-app-support copied to clipboard

Error: Too many levels of nesting to fake this schema

Open umnex opened this issue 3 years ago • 39 comments

Is there an existing issue for this?

  • [X] I have searched the tracker for existing similar issues and I know that duplicates will be closed

Describe the Issue

When I use nesting in my OpenAPI definition and generate collection. The generated examples where nesting has been used show the following error:

<Error: Too many levels of nesting to fake this schema>

Sample generated Example:

{ "meta": { "page_size": 50, "continuation_token": "A Very Long JSON String" }, "data": [ { "service": { "id": "bc73d72d-3cca-433b-8229-ab8fd0f7c2f1", "name": "Software Development" }, "posted_by": { "id": "05072d22-ab35-47ce-8d58-4ffe0d6fcda7", "name": "John Wick", "city": "Toronto", "country": "Canada", "phone": "+1 --3006", "phone_verified": true, "email": "us***@.com", "email_verified": false, "posted_on": "2017-07-21T17:32:28Z" }, "id": "05072d22-ab35-47ce-8d58-4ffe0d6fcda7", "lead_status": "pending", "credits": 22, "experts_responded": 3, "service_questions_and_answers": [ { "question_id": { "value": "<Error: Too many levels of nesting to fake this schema>" }, "question": { "value": "<Error: Too many levels of nesting to fake this schema>" }, "answer": { "value": "<Error: Too many levels of nesting to fake this schema>" } }, { "question_id": { "value": "<Error: Too many levels of nesting to fake this schema>" }, "question": { "value": "<Error: Too many levels of nesting to fake this schema>" }, "answer": { "value": "<Error: Too many levels of nesting to fake this schema>" } } ] }, { "service": { "id": "bc73d72d-3cca-433b-8229-ab8fd0f7c2f1", "name": "Software Development" }, "posted_by": { "id": "05072d22-ab35-47ce-8d58-4ffe0d6fcda7", "name": "John Wick", "city": "Toronto", "country": "Canada", "phone": "+1 --3006", "phone_verified": true, "email": "us@***.com", "email_verified": false, "posted_on": "2017-07-21T17:32:28Z" }, "id": "05072d22-ab35-47ce-8d58-4ffe0d6fcda7", "lead_status": "pending", "credits": 22, "experts_responded": 3, "service_questions_and_answers": [ { "question_id": { "value": "<Error: Too many levels of nesting to fake this schema>" }, "question": { "value": "<Error: Too many levels of nesting to fake this schema>" }, "answer": { "value": "<Error: Too many levels of nesting to fake this schema>" } }, { "question_id": { "value": "<Error: Too many levels of nesting to fake this schema>" }, "question": { "value": "<Error: Too many levels of nesting to fake this schema>" }, "answer": { "value": "<Error: Too many levels of nesting to fake this schema>" } } ] } ] }

Steps To Reproduce

  1. Import attached API Spec
  2. Generate Collection
  3. View generated successful response example under Leads --> [admin,client,expert] Returns lead list

Screenshots or Videos

image Spec.txt

Operating System

Windows

Postman Version

9.18.2

Postman Platform

Postman App

Additional Context?

No response

umnex avatar May 19 '22 13:05 umnex

Hi @umnex , thanks for reporting. I'm not able to reproduce using your example when importing when using path or tags folder organization. It looks at first glance like the 10 stack limit nesting level hasn't been reached either. Screen Shot 2022-05-19 at 11 39 12 AM

Is there a different example you're using that has more nesting happening? To get around these limits, I'd recommend checking out the openapi-to-postman project and this thread in particular where these limits are discussed for how to bypass them: https://github.com/postmanlabs/openapi-to-postman/issues/306

timbochamp avatar May 19 '22 17:05 timbochamp

Sorry I attached the spec where i solved the issue by removing the nesting. Here is the spec sample that generates issues. spec_with_issues.txt

umnex avatar May 20 '22 07:05 umnex

Hi, Is there any update to this issue?

umnex avatar May 23 '22 14:05 umnex

Sorry for the delay, @umnex. I've added a feature tag here for our Product team to review this as a feature request where the implementation will likely take time. It is a fixed limit of 10 levels of nesting I believe.

As mentioned in my last post, to get around these limits, I'd recommend checking out the openapi-to-postman project and this thread in particular where these limits are discussed for how to bypass them: postmanlabs/openapi-to-postman#306 if that's a feasible workaround in the meantime?

timbochamp avatar May 24 '22 16:05 timbochamp

Thanks for the update. I don't think I passed the 10 levels limit in my spec. Can you confirm it please?

umnex avatar May 24 '22 16:05 umnex

Let me check with our team just to be sure!

timbochamp avatar May 27 '22 18:05 timbochamp

@umnex sorry to be mistaken on my part! I spoke with @VShingala and the "Too many levels of nesting to fake this schema" problems are due to how big the spec is where there are only six layers of nesting.

As a workaround, you can turn off Optimize Conversion setting, which should prevent the deeper layers of nesting from being populated with "Too many levels of nesting to fake this schema". I verified this with your file as well. Screen Shot 2022-05-30 at 2 32 13 PM

timbochamp avatar May 30 '22 17:05 timbochamp

Going to close this out but feel free to reopen it if this issue is persisting! I'll log a ticket internally to try to better this error messaging where it's not intuitive to know to disable this Optimize conversion setting I realize.

timbochamp avatar May 31 '22 14:05 timbochamp

Thank you!

umnex avatar Jun 10 '22 14:06 umnex

Hi Team,

Turning off Optimize Conversion setting via UI does work. Is there a way to do that via the Postman API?

I am using the Automation-API Workflow and still getting the error. Documentation is not clear/ doesn't show settings available in the UI

https://www.postman.com/postman/workspace/api-first-workflow-patterns/collection/15950784-a44c86f0-a7ab-4d17-afe0-d0d5ab393b91?ctx=documentation

@timbochamp

pierre-wehbe avatar Jul 23 '22 00:07 pierre-wehbe

@umnex sorry to be mistaken on my part! I spoke with @VShingala and the "Too many levels of nesting to fake this schema" problems are due to how big the spec is where there are only six layers of nesting.

As a workaround, you can turn off Optimize Conversion setting, which should prevent the deeper layers of nesting from being populated with "Too many levels of nesting to fake this schema". I verified this with your file as well. Screen Shot 2022-05-30 at 2 32 13 PM

Turning off "Optimize conversion" worked for me... thanks a lot.

sagaofsilence avatar Aug 05 '22 02:08 sagaofsilence

@umnex @timbochamp Just making sure this doesn't get lost in translation, this works if we were to use the POSTMAN UI to import, but doesn't work via API (no field to turn off optimize conversion. Any suggestions?

pierre-wehbe avatar Aug 12 '22 18:08 pierre-wehbe

@pierre-wehbe have you tried openapi-to-postman as a workaround? https://github.com/postmanlabs/openapi-to-postman/issues/306#issuecomment-901946755

You should be able to set optimizeConversion=false that way I want to say!

timbochamp avatar Aug 16 '22 12:08 timbochamp

Hi Team,

Turning off Optimize Conversion setting via UI does work. Is there a way to do that via the Postman API?

I am using the Automation-API Workflow and still getting the error. Documentation is not clear/ doesn't show settings available in the UI

https://www.postman.com/postman/workspace/api-first-workflow-patterns/collection/15950784-a44c86f0-a7ab-4d17-afe0-d0d5ab393b91?ctx=documentation

@timbochamp

Same here

TeymurovFuad avatar Sep 15 '22 09:09 TeymurovFuad

Turning off Optimize Conversion doesn't work for me. I use collection from here: https://developer.mastercard.com/mdes-digital-enablement/documentation/api-reference/

voodooism avatar Oct 18 '22 12:10 voodooism

I am also using the POSTMAN UI to import, and turning off the "Optimize Conversion" setting doesn't work. I am still getting the "<Error: Too many levels of nesting to fake this schema>" error.

I am also not able to tell if I've reached the 10 stack limit nesting as I am not sure how exactly that's measured. Are there any updates on when this feature will be implemented?

Gunacan avatar Nov 02 '22 15:11 Gunacan

@Gunacan I got a same problem and I found a solution! It worked really well for me.

openapi2postmanv2 -s root.yaml -o collection.json -p -O folderStrategy=Tags,includeAuthInfoInExample=false,optimizeConversion=false,stackLimit=50

iksflow avatar Nov 03 '22 07:11 iksflow

@iksflow, thanks for your response, but as I said in my message, I am doing the import on Postman UI (Postman app), and not the API. The UI doesn't have the feature to set the stack limit yet; currently, you can only achieve this using the API which is what you're doing it looks like.

Gunacan avatar Nov 03 '22 13:11 Gunacan

@Gunacan Yeah, that's right. It's not cool. You already know, So I imported the collection.json(generated by CLI command) to Postman App. 🤣

iksflow avatar Nov 03 '22 14:11 iksflow

This ticket should not be marked closed as the root cause has not really been addressed.

karl-cardenas-coding avatar Nov 21 '22 18:11 karl-cardenas-coding

Reopening to track with ticket internally to try to better this error messaging or arrive at a solution not requiring openapi-to-postman as a workaround

timbochamp avatar Jan 12 '23 00:01 timbochamp

No, openapi-to-postman doesn't work for me. It's even worse because it generates only 2 levels when it comes to this situation.

lanshunfang avatar Feb 08 '23 22:02 lanshunfang

I, too, am encountering the "<Error: Too many levels of nesting to fake this schema>" error, but the suggested work-around of using openapi2postmanv2 -s root.yaml -o collection.json -p -O folderStrategy=Tags,includeAuthInfoInExample=false,optimizeConversion=false,stackLimit=50 Doesn't work for me. I still get the error in the imported collection, and from the output when running openapi2postmanv2, it doesn't seem to be using more than a stack of 10,despite being told to use up to 50:

openapi2postmanv2 -s postman.yml -o collection.json -p -O folderStrategy=Tags,requestParametersResolution=Schema,optimizeConversion=false,stackLimit=50 Warning: Invalid option supplied folderStrategy Input file: C:\Users\Nigel\Documents\postman.yml Writing to file: true C:\Users\Nigel\Documents\collection.json { result: true, output: [ { type: 'collection', data: [Object] } ], analytics: { actualStack: 10, numberOfRequests: 4, size: 0.008146286010742188, numberOfRefs: 15, numberOfExamples: 37, assignedStack: 10, complexityScore: 0 } } Conversion successful, collection written to file This is using openapi2postmanv2 v4.9.0 Any suggestions?

maldaba-nigel avatar Feb 20 '23 10:02 maldaba-nigel

Following, I also have the issue.

pmrussell892 avatar Feb 23 '23 19:02 pmrussell892

Using Version 10.11.1 of Postman UI and the setting does not work for me.

mbablok avatar Mar 08 '23 13:03 mbablok

Using Version 10.11.2 of Postman UI and the setting does not work for me.

anandsunderraman avatar Mar 13 '23 17:03 anandsunderraman

I have come back to this issue after a period of time working on other things and have stumbled-upon a solution.

It seems that if you pass the config options on the command-line, e.g: openapi2postmanv2 -s postman.yml -o collection.json -p -O folderStrategy=Tags,requestParametersResolution=Example,optimizeConversion=false,stackLimit=50 you get the "<Error: Too many levels of nesting to fake this schema>" error, but if you pass the same parameters in a JSON config file, e.g. openapi2postmanv2 -s postman.yml -o collection.json -c config.json where config.json contains:

{
  "optimizeConversion": true,
  "folderStrategy": "Tags",
  "requestParametersResolution": "Example",
  "optimizeConversion": false,
  "stackLimit": 50
}

it works as expected, with no error generated. In my case, it now claims to be using a stack of depth 11.

maldaba-nigel avatar Mar 28 '23 12:03 maldaba-nigel

@maldaba-nigel I tried this out myself with stripe API which has maximum of 27 nested levels and using same args provided as you, it's generating collection without any "<Error: Too many levels of nesting to fake this schema>" error in collection.

Could it be the case that the OpenAPI definition you're working with has more than 50 levels of nesting?

VShingala avatar Apr 13 '23 13:04 VShingala

Hey Everyone, with the recent Postman app release v10.12. We've made changes to how we generated the collection from OpenAPI definitions. To solve this issue, we've made many performance improvements and have removed the default option called Optimize conversion which was restricting the amount of nested data that was resolved.

We've also increased this limit till which we used to resolve nested data by 3 times (Now, we resolve till 30 levels of nested schema objects instead of the previous 10 levels).

Please, let us know your feedback on this if you're still facing this issue. We'll keep this issue open for some time to collect more feedback.

VShingala avatar Apr 13 '23 13:04 VShingala

I still have this issue

shae128 avatar May 05 '23 08:05 shae128