apiaryio / gavel.js

Validator of HTTP messages (JavaScript implementation)
MIT License
97 stars 22 forks source link

Stack trace exceeded for fairly small payloads #14

Closed Almad closed 10 years ago

Almad commented 11 years ago

This script


gavel  = require 'gavel'

assert = require 'assert'

response =
    statusCode: 200
    body: """
[
    {"id": 1, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 2, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 3, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 4, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 5, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 6, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 7, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 8, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 9, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 10, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 11, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 12, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 13, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 14, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 15, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 16, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 17, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 18, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 19, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 20, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 21, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 22, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 23, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 24, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"},
    {"id": 25, "a": "a", "bool": true, "b": "b", "c": "c", "d": "d", "e": "e"}
]
    """

gavel.validate response, response, 'response', (err, result) ->
    assert.equal err, null
    assert.equal result, true

will fail. result variable will contain

{ headers: 
   { length: 0,
     amandaErrors: { length: 0, errorMessages: {} },
     now: '1380048955873',
     dataError: null },
  body: 
   { '0': 
      { property: [],
        attributeValue: true,
        message: 'Validator internal error: Maximum call stack size exceeded',
        validatorName: 'error' },
     length: 1,
     amandaErrors: { '0': [Object], length: 1, errorMessages: {} },
     now: '1380048955900',
     dataError: null },
  statusCode: true }
almad@namtar /tmp $ node -v
v0.8.19
almad@namtar /tmp $ uname -a
Linux namtar 3.8.13-gentoo #2 SMP PREEMPT Sun Jun 2 16:26:50 CEST 2013 x86_64 Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz GenuineIntel GNU/Linux
Almad commented 11 years ago

This is about the minimal matrix that will lead to exceeding stack size.

Almad commented 11 years ago

Traced to the upstream library https://github.com/Baggz/Amanda/issues/68

nenadalm commented 10 years ago

I noticed that PR was sent to amanda to fix this issue: https://github.com/Baggz/Amanda/pull/32 (doesn't seems it will be fixed) - so what about to use amanda of of this guy? (https://github.com/schloerke/Amanda/branches)

nenadalm commented 10 years ago

Problem was fixed in upstream library: https://github.com/Baggz/Amanda/pull/32 and PR was sent into apiaryio/Amanda: https://github.com/apiaryio/Amanda/pull/1....