Skip to content
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

Warning on all settings.json: `$ref 'definitions/length' in {1} can not be resolved' #31932

Closed
roblourens opened this issue Aug 2, 2017 · 14 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug json JSON support issues settings-editor VS Code settings editor issues verified Verification succeeded
Milestone

Comments

@roblourens
Copy link
Member

All settings.json files show this warning:

image

@roblourens roblourens added the settings-editor VS Code settings editor issues label Aug 2, 2017
@roblourens
Copy link
Member Author

This issue was moved to hoovercj/vscode-power-mode#9

@hoovercj
Copy link
Member

hoovercj commented Aug 5, 2017

@roblourens I think there is still a vscode bug here. The error says "in {1}". Shouldn't vscode actually output what the {1} is, at least?

@roblourens
Copy link
Member Author

Possibly, the warning comes from here - https://github.com/Microsoft/vscode-json-languageservice/blob/master/src/services/jsonSchemaService.ts#L408

If you know what's triggering it in vscode-power-mode, I can investigate some more.

@hoovercj
Copy link
Member

hoovercj commented Aug 7, 2017

In this line:
resolveErrors.push(localize('json.schema.invalidref', '$ref \'{0}\' in {1} can not be resolved.', linkPath, linkedSchema.id));

The first placeholder is escaped but the second isn't. Is it a simple.matter of changing the line to:

resolveErrors.push(localize('json.schema.invalidref', '$ref \'{0}\' in \'{1}\' can not be resolved.', linkPath, linkedSchema.id));

@aeschli aeschli reopened this Aug 7, 2017
@aeschli aeschli added this to the August 2017 milestone Aug 7, 2017
@aeschli aeschli added json JSON support issues bug Issue identified by VS Code Team member as probable bug labels Aug 7, 2017
@roblourens
Copy link
Member Author

There are escaped quotes around the placeholder, but the placeholder doesn't need to be escaped.

@hoovercj
Copy link
Member

hoovercj commented Aug 7, 2017

Ok, I see now that the escaped quotes around the first placeholder are simply cosmetic and there does not need to be escaped quotes around the second placeholder.

Based on that line, though, it appears that something is preventing {1} from being replaced with the value of linkedSchema.id, or perhaps that value is undefined due to a vscode bug or, more likely, an error in my schema and that prevents the placeholder from being replaced.

I didn't write the schema myself, I found it from here.

I've gone in and added an id property at each spot in the schema that is using the length definition but I still get the error.

So I've reduced it to the minimal repro below (I added the id's hoping they would help but they did not):

What extra information is needed to make this schema valid? And can the vscode side of things be improved to make the error more useful in this scenario?

"powermode.customCss": {
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "CSS Schema",
  "id": "CSS Schema",
  "definitions": {
    "length": {
      "id": "length",
      "type": "object"
    }
  },
  "type": "object",
  "properties": {
    "border-radius": {
      "id": "border-radius",
      "$ref": "#/definitions/length"
    }
  }
}

@roblourens
Copy link
Member Author

Now I see '$ref '/definitions/length' in 'vscode://schemas/settings' can not be resolved.' which is an improvement, but it doesn't give any hint to which setting or extension is causing this, which is the real frustration. Is that possible to do?

@aeschli
Copy link
Contributor

aeschli commented Aug 31, 2017

I don't see a way to improve that as the JSON extension only sees one big schema.
I guess the only way would be to add validation to prevent $ref in the contribution point handler. But we don't want to rebuild the schema logic there.

@bpasero
Copy link
Member

bpasero commented Aug 31, 2017

I am also seeing this in latest insider, is there any help how to get out of it?

image

@aeschli
Copy link
Contributor

aeschli commented Aug 31, 2017

hoovercj/vscode-power-mode needs to fix this. It must not use $ref in the configuration contribution.

@bpasero
Copy link
Member

bpasero commented Aug 31, 2017

@aeschli thanks, that helped

@hoovercj
Copy link
Member

hoovercj commented Aug 31, 2017

I'm flattered that some of you have my extension installed and I'm sorry that it's spamming your settings.json files. I thought the fix by @aeschli was going to give more information about what was wrong with the way my $ref was being used so I could fix it in my package.json. But now it sounds like $ref isn't supported at all in the package.json so I'll simply remove it and push an update tonight. (edit: v1.2.1 is live and doesn't have this issue)

I'm confused, though, I must have misunderstood the comment by @aeschli here: #30762 (comment)

Your settings must only use the configuration contribution point....$ref should only use external refs or relative refs.

@aeschli can you elaborate on what you meant here?

I am using the configuration contribution point and I am using a relative $ref. If $ref is not supported in package.json, it should be documented here. Or if it isn't supported anywhere, it should be documented
here.

@mjbvz mjbvz added the verified Verification succeeded label Aug 31, 2017
@aeschli
Copy link
Contributor

aeschli commented Sep 1, 2017

@hoovercj Sorry for my conflicting statement.
#/definitions/length is an absolute reference (to the root of the configuration file schema), and I just realized that there is nothing like a $ref that is relative to where the $ref is used. The current thinking is that we are going to restrict what can be used in the configuration contribution point. It gets too complicated there otherwise.

@hoovercj
Copy link
Member

hoovercj commented Sep 1, 2017

Thanks for the clarification. I understand now that it is not possible. Now the error should be gone :-)

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug json JSON support issues settings-editor VS Code settings editor issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants