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

Error with $ref & nested definitions #18

Open
NathanRSmith opened this issue Jun 16, 2015 · 2 comments
Open

Error with $ref & nested definitions #18

NathanRSmith opened this issue Jun 16, 2015 · 2 comments
Labels

Comments

@NathanRSmith
Copy link

Hi all,

So came across an interesting error from Themis today. Here is a gist (https://gist.github.com/NathanRSmith/e09d671f0a72b43b781b) which illustrates the problem. It may seem contrived, but it reflects another schema that I was originally working on for declaratively building a tree-like structure.

Here is the error stack trace for the case that fails.

RangeError: Maximum call stack size exceeded
    at String.replace (native)
    at buildError (/Users/nathansmith/dev/tmp/node_modules/themis/src/themis.js:627:51)
    at ValidationGenerators.type (/Users/nathansmith/dev/tmp/node_modules/themis/src/themis.js:708:7)
    at generateSchema (/Users/nathansmith/dev/tmp/node_modules/themis/src/themis.js:1749:26)
    at Object.0#/definitions/stuff/anyStuff (/Users/nathansmith/dev/tmp/node_modules/themis/src/themis.js:1694:31)
    at generateSchema (/Users/nathansmith/dev/tmp/node_modules/themis/src/themis.js:1794:64)
    at generateSchema (/Users/nathansmith/dev/tmp/node_modules/themis/src/themis.js:1872:24)
    at generateSchema (/Users/nathansmith/dev/tmp/node_modules/themis/src/themis.js:1878:26)
    at Object.0#/definitions/stuff/stuff1 (/Users/nathansmith/dev/tmp/node_modules/themis/src/themis.js:1694:31)
    at generateSchema (/Users/nathansmith/dev/tmp/node_modules/themis/src/themis.js:1794:64)

I am not intimately familiar with the themis core, but it appears to be coming from where it builds error messages to throw if data fails validation. This error seems to be building a message that has the path of the circular "$ref" and there is a recursion error. But what is interesting is that it only does this when I have my definitions grouped and not when things are a bit flatter, despite there still being cycles...

Anyone have any insight as to why this is happening? I think I can work around it in my real schema for now by keeping things flat, but other validators (tv4, is-my-json-valid) are able to validate without issue.

$ node --version
v0.12.0
$ npm ls
/Users/nathansmith/dev/tmp
└─┬ themis@1.1.5
  └─┬ uglify-js@2.4.15
    ├── async@0.2.10
    ├─┬ optimist@0.3.7
    │ └── wordwrap@0.0.3
    ├─┬ source-map@0.1.34
    │ └── amdefine@0.1.1
    └── uglify-to-browserify@1.0.2
@pyrossh
Copy link

pyrossh commented Jun 17, 2015

I don't think themis is tested on node v0.12.0? Maybe it would work on node v0.10.33.

@NathanRSmith
Copy link
Author

Just tried, same error.

@kumarharsh kumarharsh added the bug label Aug 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants