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

Stack level too deep in docker container #1

Closed
Tall-Paul opened this issue Jun 24, 2019 · 5 comments
Closed

Stack level too deep in docker container #1

Tall-Paul opened this issue Jun 24, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@Tall-Paul
Copy link

Using this command:

docker run -v 'c:/Users/blah/Desktop/openapi.json:/home/openapi.json' -p 8081:8080 realfengjia/fakeit:latest --spec /home/openapi.json

getting this stack trace:

/usr/local/bundle/gems/openapi_parser-0.3.0/lib/openapi_parser/concerns/findable.rb:31:in each': stack level too deep (SystemStackError) from /usr/local/bundle/gems/openapi_parser-0.3.0/lib/openapi_parser/concerns/findable.rb:31:in purge_object_cache'
from /usr/local/bundle/gems/openapi_parser-0.3.0/lib/openapi_parser/concerns/findable.rb:31:in each' from /usr/local/bundle/gems/openapi_parser-0.3.0/lib/openapi_parser/concerns/findable.rb:31:in purge_object_cache'
from /usr/local/bundle/gems/openapi_parser-0.3.0/lib/openapi_parser/concerns/findable.rb:31:in each' from /usr/local/bundle/gems/openapi_parser-0.3.0/lib/openapi_parser/concerns/findable.rb:31:in purge_object_cache'
from /usr/local/bundle/gems/openapi_parser-0.3.0/lib/openapi_parser/concerns/findable.rb:31:in each' from /usr/local/bundle/gems/openapi_parser-0.3.0/lib/openapi_parser/concerns/findable.rb:31:in purge_object_cache'
from /usr/local/bundle/gems/openapi_parser-0.3.0/lib/openapi_parser/concerns/findable.rb:31:in each' ... 11756 levels... from /usr/local/bundle/gems/fakeit-0.1.3/lib/fakeit.rb:14:in build'
from /usr/local/bundle/gems/fakeit-0.1.3/bin/fakeit:44:in <top (required)>' from /usr/local/bundle/bin/fakeit:23:in load'
from /usr/local/bundle/bin/fakeit:23:in `

'

@JustinFeng
Copy link
Owner

JustinFeng commented Jun 25, 2019

Hi @Tall-Paul, thank you for your feedback

From the stack trace, looks like it's a runtime error raised from openapi_parser when it tries to purge cached json schema object cache. Potentially could be caused by

  • bad recursion code in openapi_parser gem, or
  • recursive ref in the specification, or
  • deep ref stack limited by docker image `stack size setting (less likely as the same method has been called 11756 times recursively)

Would you mind provide a specification file (remove any sensitive information), so that I can reproduce the issue and confirm the root cause locally

@JustinFeng
Copy link
Owner

I got the same stack trace with recursive ref in specification file, like this

  "components": {
    "schemas": {
      "get_response": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/reccur"
          }
        }
      },
      "reccur": {
        "type": "object",
        "properties": {
          "data1": {
            "$ref": "#/components/schemas/sive"
          }
        }
      },
      "sive": {
        "type": "object",
        "properties": {
          "data2": {
            "$ref": "#/components/schemas/reccur"
          }
        }
      }
    }
  }

Created an issue in https://github.com/ota42y/openapi_parser

@JustinFeng
Copy link
Owner

JustinFeng commented Jun 25, 2019

FYI, even the parser issue is fixed, random example generation may face the same infinite recursive issue, suggestion will be providing the example property for recursive schema part and specify --use-example option when you run fakeit command

@Tall-Paul
Copy link
Author

Hi Justin, good catch, it was indeed a recursive reference in the definition! Thanks for your help, I've amended our definition to remove the recursive references which got me past this issue. I'm now getting another problem, but I'll open another issue for that.

@JustinFeng
Copy link
Owner

Created a monkey patch to fix the recursive schema reference before it get solved in openapi_parser

@JustinFeng JustinFeng added the bug Something isn't working label Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants