Skip to content

Stack overflow when using recursive references, $ref #180

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

Closed
davidvisiedo opened this issue Aug 7, 2019 · 3 comments
Closed

Stack overflow when using recursive references, $ref #180

davidvisiedo opened this issue Aug 7, 2019 · 3 comments

Comments

@davidvisiedo
Copy link
Contributor

davidvisiedo commented Aug 7, 2019

I think this issue is related to #59 and #36.

I get a stack overflow when refs are recursive (example copied from #59).

Related to https://json-schema.org/latest/json-schema-core.html#rfc.section.8.3.1

"A schema MUST NOT be run into an infinite loop against a schema. For example, if two schemas "#alice" and "#bob" both have an "allOf" property that refers to the other, a naive validator might get stuck in an infinite recursive loop trying to validate the instance. Schemas SHOULD NOT make use of infinite recursive nesting like this; the behavior is undefined. "

Example:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "parent": {
      "$ref": "#/definitions/objectDef"
    }
  }
},
"definitions": {
  "objectDef": {
    "type": "object",
    "properties": {
      "value1": {
        "type": "string"
      },
      "value2": {
        "type": "string"
      },
      "childObject": {
        "$ref": "#/definitions/objectDef"
      }
    }
  }
}
@davidvisiedo davidvisiedo changed the title Recursive $ref gets stack overflow Stack overflow when using recursive references, $ref Aug 7, 2019
@davidvisiedo
Copy link
Contributor Author

Code uploaded, Push Request #181

@stevehu
Copy link
Contributor

stevehu commented Aug 7, 2019

@davidvisiedo The implementation makes perfect sense. I have asked other developers to review the code as they know more about this area. Thanks a lot for your help.

stevehu added a commit that referenced this issue Aug 7, 2019
Fix issue #180: Prevents recursive parsing of $ref references.
@stevehu
Copy link
Contributor

stevehu commented Aug 7, 2019

@davidvisiedo I have merged the PR to the master branch. Wait for another PR to be reviewed/tested to have another release. Thanks a lot for your help.

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

No branches or pull requests

2 participants