Skip to content

JSON Schema: cyclic references resolve to wrong path #113993

@PiIsFour

Description

@PiIsFour

VSCode Version: 1.53.0-insider (user setup)
Commit: 01089c0
Date: 2021-01-07T05:22:09.742Z
Electron: 11.1.0
Chrome: 87.0.4280.88
Node.js: 12.18.3
V8: 8.7.220.29-electron.0
OS: Windows_NT x64 10.0.19042

Steps to Reproduce:

  1. If we have two schema files that reference each other

test.schema.json

{
  "$schema": "http://json-schema.org/draft-07/schema",
  "oneOf": [
    {
      "type": "boolean"
    },
    {
      "$ref": "generic/node.schema.json"
    }
  ]
}

generic/node.schema.json

{
  "$schema": "http://json-schema.org/draft-07/schema",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "left": {
      "$ref": "../test.schema.json"
    },
    "right": {
      "$ref": "../test.schema.json"
    }
  }
}
  1. in a schema file that uses this we get an error about not being able to find the file
    Problems loading reference 'file:///d%3A/projects/test.schema.json': Unable to load schema from 'd:\projects\test.schema.json': ENOENT: no such file or directory, open 'd:\projects\test.schema.json'.
    which is one folder to high.
  2. switching to "$ref": "./test.schema.json" does not help because it is rightly a folder to low.
  3. if both files are in the same folder the two cyclic refs work fine
  4. if you remove the second ref (right) it will also work so relative paths are also wirking

Not sure why this combination of things stoops it from working. I would be glad if this is fixable because it seemed to work in 1.51. Please let me know if you need any more information or I'm doing something wrong. Thanks.

Does this issue occur when all extensions are disabled?: Yes

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugjsonJSON support issuesverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions