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

Custom tags not working #137

Closed
rvansa opened this issue Nov 16, 2018 · 15 comments
Closed

Custom tags not working #137

rvansa opened this issue Nov 16, 2018 · 15 comments
Milestone

Comments

@rvansa
Copy link

rvansa commented Nov 16, 2018

I have trouble getting the custom tags working. This are my user settings:

cat ~/.config/Code/User/settings.json

{
    "workbench.editor.enablePreview": false,
    "workbench.editor.enablePreviewFromQuickOpen": false,
    "yaml.customTags": [ "!rampPerSec", "!constantPerSec"]
}

and this is the yaml that fails to be parsed:

foo:
  - !constantPerSec bar: gee

VSCode version: 1.28.2
YAML Support by Red Hat version: 0.1.0
possibly conflicting plugin? Ansible 0.5.2 (extension association is to YAML, not ansible, though).

I'll be grateful for any hints. I've tried restarting VSCode couple of times, or placing the yaml.customTags to workspace settings instead but it did not help. Removing exclamation marks didn't help either. Thank you.

@JPinkney
Copy link
Contributor

What errors are you getting?

@rvansa
Copy link
Author

rvansa commented Nov 19, 2018

!con is underlined with unknown tag <!constantPerSec>
: gee is underlined with bad indentation of sequence entry

@JPinkney
Copy link
Contributor

I think in this case you would technically need to do:

"yaml.customTags": [
"!constantParSec sequence"
]

However it looks like there are quite a few bugs in custom tags right now anyways so that won't work currently. I'm working on a fix

@rvansa
Copy link
Author

rvansa commented Nov 19, 2018

That gets me only halfway: With !constantPerSec sequence the : gee is underlined with
unacceptable node kind for !<!constantPerSec> tag; it should be "sequence", not "scalar"

When I try !constantPerSec scalar, it complains about indentation...

Do you plan to include 'any' type as well? Or will you make sure that the same tag can be applied to multiple types? Thanks.

@JPinkney
Copy link
Contributor

Currently, there are no plans to include (the code that has the issue doesn't live here it lives in http://github.com/mulesoft-labs/yaml-ast-parser/issues iirc).

Or will you make sure that the same tag can be applied to multiple types? Thanks.

I hope to do this/someone adds this in the future, it would be very useful.

@AndyJPhillips
Copy link

I'm was getting a similar problem (Cloudformation yaml tags were causing unknown tag errors), I managed to 'fix' it by:

  • disabling all dependent VSCode extensions (Ansible etc)
  • disabling the YAML extension
  • re-enable the YAML extension

For reference my versions are:

VSCode: 1.30.2
YAML extension: 0.2.1

Here's my yaml.customTags:

"yaml.customTags": [ "!And sequence", "!Equals sequence", "!If sequence", "!Not sequence", "!Or sequence", "!Base64", "!Cidr sequence", "!FindInMap sequence", "!GetAtt", "!GetAZs", "!ImportValue", "!Join sequence", "!Select sequence", "!Split sequence", "!Sub", "!Ref" ]

@AndyJPhillips
Copy link

In more news - as soon as I re-enable the Ansible 0.5.2 extension and reload it breaks the yaml custom tags

@efim-a-efim
Copy link

Same problem here. Looks like Ansible extension breaks YAML custom tags functionality.

@JPinkney JPinkney added this to the 0.4.0 milestone Mar 12, 2019
@JPinkney
Copy link
Contributor

The ansible extension uses a fork of this one for some reason 🤷‍♂️ and because of that we can't actually stop it from showing the error see: #178 but it looks like the actual issue was fixed so I'm going to close the issue

@smiller171
Copy link

I'm not able to get it working even after disabling the Ansible extension unfortunately.

@JPinkney
Copy link
Contributor

@smiller171 Can you open a new issue with your custom tags and also a picture whats in the text document (similar to what was posted in the issue) and other extensions installed.

@mil1i
Copy link

mil1i commented Dec 20, 2019

I have also tried @AndyJPhillips method above and am not able to get custom tags to work after disabling all extensions and re-enabling just the YAML extension.

I have tried removing all custom tags and just trying one at a time. None are working. I am trying to get the Cloudformation (!Ref, !Sub, etc) custom tags to work.

I've tried with just !Ref, !Sub. I've tried !Sub scalar, !Sub sequence, !Sub mapping. Nothing.

Screen Shot 2019-12-20 at 11 08 38 AM


EDIT:
So apparently not only does the Ansible extension break customTags, also the Cloud Code extension breaks it.

If you copy your "yaml.customTags" in settings and add the same to "cloudcode.yaml.customTags", this fixes it.

Also with the Ansible extension enabled, if you set "ansible.validation": false the customTags will still work as well.

@abohne
Copy link

abohne commented Dec 23, 2019

I posted another workaround at VSChina/vscode-ansible#230 (comment).

@ssbarnea
Copy link
Member

Or to rephrase this bug is caused by adamvoss/vscode-yaml#16 extension which hijacks yaml customTagsconfig and overrides it for all YAML files, not only for Ansible ones, breaking a huge number of YAML tools.

@cweekly
Copy link

cweekly commented Dec 3, 2021

FWIW, on MacOS 11.6.1, latest VSCode 1.62.3, extension v1.2.2, I was annoyed by supposed syntax errors in yml files (.gitlab-ci.yml, cicd/*.yml) containing lines like !reference [.basic_no_merge_rules, rules].

AFAICT, the GitLab Workflow extension still can't properly validate yml files with custom tags like "!reference", but thanks to the comments here, I could at least get rid of the syntax errors:

  "yaml.customTags": [
    "!reference sequence"
  ], 

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

9 participants