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.

[BUG] [go-server] Code generation failed (maybe infinite recursion?)

See original GitHub issue

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What’s the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What’s the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

I found error trying to generate server code using a large yaml definition and noticed the issue. I have been able to reproduce the issue using a set of minimal yaml files.

The cause of error is about the TestType, which has been defined multiple times in multiple files and indirectly referenced.

The error looks like stack overflow caused by infinite recursion.

[main] INFO  o.o.codegen.DefaultGenerator - Model Error not generated since it's a free-form object
Exception in thread "main" java.lang.StackOverflowError
	at org.openapitools.codegen.utils.ModelUtils.hasOrInheritsDiscriminator(ModelUtils.java:1327)
	at org.openapitools.codegen.utils.ModelUtils.hasOrInheritsDiscriminator(ModelUtils.java:1338)
...
openapi-generator version

The docker cli openapitools/openapi-generator-cli

OpenAPI declaration file content or url

Sample yaml files are available in https://github.com/ztai-goog/bugreport/tree/master/openapi_codegen_1

Command line used for generation
docker run --rm \
    -v $PWD:/local openapitools/openapi-generator-cli generate \
    -i /local/petstore.yaml \
    -g go-server \
    -o /local/go_server
Steps to reproduce

cd into the directory of yaml files and run the generation command above.

Related issues/PRs
Suggest a fix

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
selimokcommented, May 13, 2021

In my case it was a faulty openapi spec which contains cyclic $refs. After fixing that, everything came back to normal.

0reactions
selimokcommented, May 12, 2021

Same problem here. I tried with different versions of openapi-generator-cli and only working version was 3.3.4 (I didn’t tried older versions) Unfortunately, I’m not allowed to share openapi specs here. But I will try to locate problem cause in the next days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug #81062 :: Infinite recursion causes a segmentation fault
Any code that can make PHP segfault is a bug, especially when no special extensions are at play. This specific bug has been...
Read more >
Bug listing with status CONFIRMED as at 2022/12/07 04:46:31
status:CONFIRMED resolution: severity:enhancement · Bug:21509 - "[PATCH] [IDEA] Ability to cleanly stop emerging multiple packages after the current jobs ...
Read more >
Infinite Recursion with Jackson JSON and Hibernate JPA issue
This part of the relationship will be re-constructed during the deserialization (unmarshalling) of the forward reference. You can change your code like this...
Read more >
How can I prevent an infinite recursion within my program?
I am trying to run the code below, and I get very long error message ... The likely cause is an infinite recursion...
Read more >
EntityDrupalWrapper->value() causes infinite recursion on ...
are you sure the user is logged in and you have a full $user object available in your rule? Maybe you have to...
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