Comments (19)
from yaml-language-server.
Can you post the YAML? That isn't actually an error per se its just saying there are multiple sub schemas inside of the Kubernetes schema it matches so therefore it doesn't know which one to verify against.
from yaml-language-server.
@JPinkney here is one:
apiVersion: apps/v1
kind: Deployment
metadata:
name: app
spec:
selector:
matchLabels:
app: app
replicas: 1
template:
metadata:
labels:
app: app
spec:
containers:
- name: app
image: nginx
volumes:
- name: config-volume
configMap:
name: app-config
---
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
config: some config
Let's call it a feature request then: the editor should be able to apply the schema up to the next ---
:)
from yaml-language-server.
Which version of the language server are you using (or the version of VSCode-YAML if you're using that)? If you aren't using VSCode-YAML which code editor/IDE are you using? It doesn't get that error on my side so I'm not sure if its version difference or something else.
from yaml-language-server.
@JPinkney I am using the latest version of the vscode plugin available in the vscode extension store: 0.0.14.
I realise it isn't the latest according to github but I have no idea how to update except waiting for it to be available on the extension store.
from yaml-language-server.
hm actually, I'm confusing the repository for the extension and the repository for the language server: the extension is the latest, but I don't know which version of the language server it is using… maybe not the latest
from yaml-language-server.
If you're using VSCode 0.0.14 then its using the latest available version of the yaml language server. However, for some reason I cannot reproduce so I'm going to try and see if I can reproduce on a few co-workers machines.
Which OS are you using? and which VSCode version? Maybe those will help narrow it down.
from yaml-language-server.
It is vscode 1.25.1 on an up to date archlinux.
If I can do something don't hesitate.
from yaml-language-server.
Hmm, my co-worker and I are on Fedora and we do not get the error with that yaml for some reason. I'll probably need you to do a few things if you don't mind.
First, I'll need your yaml preferences from VSCode and then I'll need you to set yaml.trace.server to be verbose (Basically it just shows all the language server/client request logs). Then you should be able to see the logs in the output tab and then the YAML Support output tab inside of that. Then can you paste your log from that? I think that will help get to the bottom of it!
from yaml-language-server.
Here are my settings (they are all defaults):
// Configure editor settings to be overridden for [yaml] language.
"[yaml]": {
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": true
},
"editor.autoIndent": false
},
// Custom tags for the parser to use
"yaml.customTags": [],
// Enable/disable default YAML formatter (requires restart)
"yaml.format.enable": false,
// Associate schemas to Yaml files in the current workspace
"yaml.schemas": {},
// Traces the communication between VSCode and the languageServerExample service.
"yaml.trace.server": "off",
// Enable/disable validation feature
"yaml.validate": true
Here are the logs when I open the file: https://gist.github.com/victornoel/3f1ca3ef85cbd15e92f45f619dff6009
And here are the logs when I open vscode and the file (so there is a lot): https://gist.github.com/victornoel/b44b5fc74f26ab045390ddf912b24870
from yaml-language-server.
Ah are you by any chance using https://github.com/Azure/vscode-kubernetes-tools? (Or some other kubernetes extension that depends on this language server)
from yaml-language-server.
@JPinkney good point, I am indeed using this extension (ms-kubernetes-tools.vscode-kubernetes-tools
).
If I disable it, there are no errors, but I don't feel like validation is doing anything, for example if I use a string for the value of replicas
in the example above, the editor does not complain about it.
If I do the same in a file containing only the Deployment
of the example above, an error is shown to tell me I should input an integer there.
Am I correct in understanding that it is the kubernetes extension that actually takes care of validation and schema related behaviour?
from yaml-language-server.
if I disable it, there are no errors, but I don't feel like validation is doing anything, for example if I use a string for the value of replicas in the example above, the editor does not complain about it.
Thats because by default VSCode-YAML doesn't attach a schema to the current file you're editing so it doesn't have contextual awareness of what is going on. Rather, it just has basic validation stuff. If you want to attach a schema you can look here and the validation stuff will be there.
Am I correct in understanding that it is the kubernetes extension that actually takes care of validation and schema related behaviour?
The kubernetes extension has an end point where they can programmically set the schemas inside the yaml language server. So the yaml-language-server takes care of handling the schemas whereas the kubernetes extension takes care of adding the schemas (but anyone can also add schemas manually themselves using the yaml.schemas setting). However, I think this means the reason you're getting the error above (matching mulitple schemas) is because the piece of YAML you wrote matches two of the schemas they added and thus doesn't know which one to validate against. I don't think there is anything I can do from my side because its an issue with the schemas, the yaml language server just throws the error to let the user know.
from yaml-language-server.
@JPinkney ok, so I will open an issue there and close this one once I'm sure there is nothing that is needed to be done here to make the whole works :)
thanks again for your patience!
from yaml-language-server.
See vscode-kubernetes-tools/vscode-kubernetes-tools#341 :)
from yaml-language-server.
@victornoel @JPinkney The problems are caused by the differences between json and yaml document: one json file only has one document while one yaml file can have multiple documents, in this case(multiple document), the current behavior for k8s schema provider is to provide anyOf [Deployment, ConfigMap] for the specified yaml, this works well if no validation problems/errors found, but if any errors are founded, for example the second ConfigMap has some validation errors, then the yaml-languange-server will not be able to detect which schema is actually chosen since both [Deployment, ConfigMap] schema is not acceptable, and it will use the first one Deployment to report the errors. The solution to this scenario is to notice the getSchemaForResource
may return an Array if multiple documents are detected rather than the tricky anyOf schema to represent multiple documents, I am preparing for the PR.
from yaml-language-server.
https://github.com/redhat-developer/yaml-language-server/pull/81/files
from yaml-language-server.
@andxu cool, glad to see the solution was easy :)
from yaml-language-server.
This has been fixed by @andxu and a new version of VSCode-YAML and yaml-language-server have been released.
from yaml-language-server.
Related Issues (20)
- Add support for ignoring individual schema validation errors HOT 2
- TypeError: Cannot create property 'url' on string 'object'
- Completion suggestions for arrays, integers suggest ${} placeholders
- Numbers in comments HOT 1
- Don't send workspace/configuration to clients that don't support it HOT 1
- Prettifying Example Payload Stopped Working
- `- array item` suggestion gives extra line HOT 1
- `rangeFormatting` is used to register whole-document `formatting` capability
- Remove formatting provider HOT 4
- Yaml cant seem to process draft-4/7 schema editing HOT 1
- yaml is not validating correctly the config.yml file for github
- openapi discriminators
- Proposal for Donating the yaml-language-server Project to an Open Governance Foundation HOT 4
- Show enum values on hover HOT 1
- Github workflow deploy.yml detected as a PHP Deployer config
- docs: The examples in the README have their syntax set wrong
- YAML `---` for "Multiple documents within a single stream" doesn't work [YAML Language Server] HOT 1
- Cannot Load content for: schema.json Unknown schema: file
- URL fragment references does not resolve correctly
- Use inline JSON Schema w/o modeline - make `yaml-language-server` string optional
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yaml-language-server.