Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Maximum call stack size exceeded when validating recursive models #62

Closed
morris opened this issue Sep 20, 2016 · 3 comments
Closed

Maximum call stack size exceeded when validating recursive models #62

morris opened this issue Sep 20, 2016 · 3 comments

Comments

@morris
Copy link

morris commented Sep 20, 2016

Running this

var express = require( 'express' );
var swagger = require( 'swagger-express-middleware' );
var request = require( 'request' );

var app = express();

swagger( {
  swagger: '2.0',
  info: {
    version: '1.0',
    title: 'Bug'
  },
  consumes: [
    'application/json'
  ],
  paths: {
    '/': {
      post: {
        parameters: [
          {
            name: 'payload',
            in: 'body',
            required: true,
            schema: {
              $ref: '#/definitions/Node'
            }
          }
        ]
      }
    }
  },
  definitions: {
    Node: {
      type: 'object',
      properties: {
        name: {
          type: 'string'
        },
        child: {
          $ref: '#/definitions/Node'
        }
      }
    }
  }
}, app, function ( err, middleware ) {

  app.use(
    middleware.metadata(),
    middleware.parseRequest(),
    middleware.validateRequest()
  );

  app.listen( 8000, function() {

    request( {
      url: 'http://localhost:8000',
      method: 'POST',
      headers: {
        'Content-type': 'application/json'
      },
      body: JSON.stringify( {
        name: 'lol'
      } )
    }, function ( err, res, body ) {
      console.log( err, body );
    } );

  } );

} );

results in

Error: The "payload" body parameter is invalid ({"test":"lol"}) 
<br>Maximum call stack size exceeded
<br> &nbsp; &nbsp;at ono (/node_modules/swagger-express-middleware/node_modules/ono/lib/index.js:62:17)
<br> &nbsp; &nbsp;at parseParameter (/node_modules/swagger-express-middleware/lib/param-parser.js:146:11)
<br> &nbsp; &nbsp;at /node_modules/swagger-express-middleware/lib/param-parser.js:93:18
<br> &nbsp; &nbsp;at Array.some (native)
<br> &nbsp; &nbsp;at parseBodyParam (/node_modules/swagger-express-middleware/lib/param-parser.js:77:10)
<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
<br> &nbsp; &nbsp;at trim_prefix (/node_modules/express/lib/router/index.js:312:13)
<br> &nbsp; &nbsp;at /node_modules/express/lib/router/index.js:280:7
<br> &nbsp; &nbsp;at Function.process_params (/node_modules/express/lib/router/index.js:330:12)
<br> &nbsp; &nbsp;at next (/node_modules/express/lib/router/index.js:271:10) 
<br>
<br>RangeError: Maximum call stack size exceeded
<br> &nbsp; &nbsp;at Function.isArray (native)
<br> &nbsp; &nbsp;at normSchema (/node_modules/swagger-express-middleware/node_modules/tv4/tv4.js:1334:13)
<br> &nbsp; &nbsp;at normSchema (/node_modules/swagger-express-middleware/node_modules/tv4/tv4.js:1344:6)
<br> &nbsp; &nbsp;at normSchema (/node_modules/swagger-express-middleware/node_modules/tv4/tv4.js:1344:6)
<br> &nbsp; &nbsp;at normSchema (/node_modules/swagger-express-middleware/node_modules/tv4/tv4.js:1344:6)
<br> &nbsp; &nbsp;at normSchema (/node_modules/swagger-express-middleware/node_modules/tv4/tv4.js:1344:6)
<br> &nbsp; &nbsp;at normSchema (/node_modules/swagger-express-middleware/node_modules/tv4/tv4.js:1344:6)
<br> &nbsp; &nbsp;at normSchema (/node_modules/swagger-express-middleware/node_modules/tv4/tv4.js:1344:6)
<br> &nbsp; &nbsp;at normSchema (/node_modules/swagger-express-middleware/node_modules/tv4/tv4.js:1344:6)
<br> &nbsp; &nbsp;at normSchema (/node_modules/swagger-express-middleware/node_modules/tv4/tv4.js:1344:6)

Here's npm ls

@morris morris changed the title Maximum callstack exceeded when validating recursive models Maximum call stack size exceeded when validating recursive models Sep 20, 2016
@Akuryou
Copy link

Akuryou commented Oct 18, 2016

I can confirm this, got the same issue.

@baronfel
Copy link

The underlying issue seems to be a problem with tv4 normalizing and reading the recursive schemas. I've started a discussion over at geraintluff/tv4#249 to try and address the underlying problem.

@rkrauskopf
Copy link
Member

Closing this issue due to its age. Please re-open it if the issue is still relevant

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants