yaml-language-server icon indicating copy to clipboard operation
yaml-language-server copied to clipboard

`Matches a schema that is not allowed` error, but the ansible-playbook script runs fine.

Open David-Else opened this issue 2 years ago • 3 comments

Hi,

My first attempt to use ansible has been thwarted by red squiggles.

I have installed this language server and am using the Helix editor that works with it out-of-the-box. My first script works running ansible-playbook , but I am told Matches a schema that is not allowed, and I have looked at the Helix logs and it seems to be using the correct https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible.json

- name: Bootstrap development environment
  hosts: localhost

  tasks:
  - name: Install Stow on redhat clones
    become: true
    dnf:
      name:
        - stow
      state: present

Screenshot from 2023-01-20 16-48-36 Screenshot from 2023-01-20 16-50-07

What exactly does this message mean? It doesn't really make sense, does it mean ansible.json is not allowed? What can I do about this problem? I would like it to help me with ansible.

Also I have no formatting available, it is turned of by default? That would be a strange choice? Cheers.

David-Else avatar Jan 20 '23 16:01 David-Else

The message is emitted when a section matches the "not" section of the schema. Granted that the message could be better. We need to check if this is the schema or the validation logic causing the unexpected behaviour. @ssbarnea FYI

gorkem avatar Jan 22 '23 16:01 gorkem

@gorkem is there a way to influence the message from not validation, it's way too vague right now? It also seems inconsistent with what I've seen so far, for example, it doesn't take title into consideration:

"not": {
  "title": "Must not contain SINCE or UNTIL",
  "pattern": "(SINCE|UNTIL)"
}

nieomylnieja avatar Feb 16 '23 19:02 nieomylnieja

@nieomylnieja Currently, there is no way to influence the message. It is a fixed message. title may help. Perhaps we can change the error message to something like Matches subschema $title | $path but schema does not allow it

gorkem avatar Mar 24 '23 17:03 gorkem