djv icon indicating copy to clipboard operation
djv copied to clipboard

Stack overflow error

Open nahidakbar opened this issue 6 years ago • 2 comments

Test case


var djv = require("djv")

var env = djv();

env.addSchema('test', {
    "$schema": "http://json-schema.org/schema#",
    "title": "Aspect capturing a complete representation of a distribution according to Project Open Data (data.json).",
    "type": "object",
    "allOf": [
      {
        "$ref": "https://project-open-data.cio.gov/v1.1/schema/distribution.json"
      }
    ]
  })
  
env.validate('test#', {
    "@type": "dcat:Distribution",
    "downloadURL": "dataset-url/dataset.csv",
    "mediaType": "text/csv"
});

nahidakbar avatar Sep 14 '18 01:09 nahidakbar

undefined:23
    }, f3 = function f0(data) {
                       ^

RangeError: Maximum call stack size exceeded
    at f0 (eval at restore (/djv/lib/utils/template.js:124:15), <anonymous>:23:24)
    at f0 (eval at restore (/djv/lib/utils/template.js:124:15), <anonymous>:16:5)
    at f0 (eval at restore (/djv/lib/utils/template.js:124:15), <anonymous>:30:9)
    at f0 (eval at restore (/djv/lib/utils/template.js:124:15), <anonymous>:16:5)
    at f0 (eval at restore (/djv/lib/utils/template.js:124:15), <anonymous>:30:9)
    at f0 (eval at restore (/djv/lib/utils/template.js:124:15), <anonymous>:16:5)
    at f0 (eval at restore (/djv/lib/utils/template.js:124:15), <anonymous>:30:9)
    at f0 (eval at restore (/djv/lib/utils/template.js:124:15), <anonymous>:16:5)
    at f0 (eval at restore (/djv/lib/utils/template.js:124:15), <anonymous>:30:9)
    at f0 (eval at restore (/djv/lib/utils/template.js:124:15), <anonymous>:16:5)

korzio avatar May 03 '19 13:05 korzio

@nahidakbar I've added 2 tests for the failing case

https://github.com/korzio/djv/blob/issues-71-exceed-maximum-call-stack/test/issues/71.js#L21

  1. should throw reference error when schema is not found, should not exceed maximum call stack

Checks if the correct error is thrown when validator cannot find a schema. The validator is not responsive for downloadштп remote schema. User should add schema to the validator's environment himself. The error type is not final, can be changed during development.

  1. should resolve local existing reference

Checks if an instance is validated correctly against the existing local schema

Please comment if you have any objections or additional thoughts, thanks!

korzio avatar May 25 '19 16:05 korzio