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

Yaml custom tags, unresolved tags #18013

Open
1 task done
elvishp2006 opened this issue Sep 18, 2024 · 15 comments · Fixed by #18081
Open
1 task done

Yaml custom tags, unresolved tags #18013

elvishp2006 opened this issue Sep 18, 2024 · 15 comments · Fixed by #18081
Labels
bug [core label] language server An umbrella label for all language servers regression A bug that was introduced in a recent release yaml YAML data format support

Comments

@elvishp2006
Copy link

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

I had configured my editor to work with a custom lsp config to yaml files, but it keep saying that my custom tags are Unresolved

Environment

Zed: v0.153.5 (Zed Preview)
OS: macOS 14.6.1
Memory: 16 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

  "lsp": {
    "yaml-language-server": {
      "initialization_options": {
        "yaml": {
          "customTags": [
            "!And scalar",
            "!And mapping",
            "!And sequence",
            "!If scalar",
            "!If mapping",
            "!If sequence",
            "!Not scalar",
            "!Not mapping",
            "!Not sequence",
            "!Equals scalar",
            "!Equals mapping",
            "!Equals sequence",
            "!Or scalar",
            "!Or mapping",
            "!Or sequence",
            "!FindInMap scalar",
            "!FindInMap mappping",
            "!FindInMap sequence",
            "!Base64 scalar",
            "!Base64 mapping",
            "!Base64 sequence",
            "!Cidr scalar",
            "!Cidr mapping",
            "!Cidr sequence",
            "!Ref scalar",
            "!Ref mapping",
            "!Ref sequence",
            "!Sub scalar",
            "!Sub mapping",
            "!Sub sequence",
            "!GetAtt scalar",
            "!GetAtt mapping",
            "!GetAtt sequence",
            "!GetAZs scalar",
            "!GetAZs mapping",
            "!GetAZs sequence",
            "!ImportValue scalar",
            "!ImportValue mapping",
            "!ImportValue sequence",
            "!Select scalar",
            "!Select mapping",
            "!Select sequence",
            "!Split scalar",
            "!Split mapping",
            "!Split sequence",
            "!Join scalar",
            "!Join mapping",
            "!Join sequence",
            "!Condition scalar",
            "!Condition mapping",
            "!Condition sequence"
          ],
          "schemas": {
            "https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json": "template.yml"
          }
        }
      }
    }
  }
Captura de Tela 2024-09-18 às 12 15 41

If applicable, attach your Zed.log file to this issue.

Zed.log
@elvishp2006 elvishp2006 added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Sep 18, 2024
@notpeter
Copy link
Member

Can you provide an minimal example YAML file so I can see if I can reproduce?

@notpeter notpeter added yaml YAML data format support language server An umbrella label for all language servers and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Sep 18, 2024
@elvishp2006
Copy link
Author

Can you provide an minimal example YAML file so I can see if I can reproduce?

AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
  api-example: API Example

Parameters:
  Stage:
    Type: String
    Default: development
    AllowedValues:
      - development
      - staging
      - production

Conditions:
  IsProductionStage: !Equals [!Ref Stage, production]

Resources:
  HttpApi:
    Type: AWS::Serverless::HttpApi
    Properties:
      DefaultRouteSettings:
        DetailedMetricsEnabled: true
      Domain:
        CertificateArn: arn:aws:acm:us-east-1:000000000000:certificate/be8e5595-4771-4408-9ec2-547a2230bdfds
        DomainName: !Ref DomainName
        EndpointConfiguration: REGIONAL
        Route53:
          HostedZoneId: Z1OLBJHSKHIU98

@notpeter
Copy link
Member

I can reproduce. You config works correctly in 2d06d5c following this PR:

But is broken in current Stable/Preview.

After running the bisect the offending commit that introduced the regression is 02d5f32 which is the following PR:

Thanks for reporting.

@notpeter notpeter added the regression A bug that was introduced in a recent release label Sep 19, 2024
@notpeter
Copy link
Member

Change initialization_options to settings and it should work.
I'll work on updating the docs to reflect this.

@elvishp2006
Copy link
Author

I had changed the configs to this:

  "lsp": {
    "yaml-language-server": {
      "settings": {
        "yaml": {
          "customTags": [
            "!And scalar",
            "!And mapping",
            "!And sequence",
            "!If scalar",
            "!If mapping",
            "!If sequence",
            "!Not scalar",
            "!Not mapping",
            "!Not sequence",
            "!Equals scalar",
            "!Equals mapping",
            "!Equals sequence",
            "!Or scalar",
            "!Or mapping",
            "!Or sequence",
            "!FindInMap scalar",
            "!FindInMap mappping",
            "!FindInMap sequence",
            "!Base64 scalar",
            "!Base64 mapping",
            "!Base64 sequence",
            "!Cidr scalar",
            "!Cidr mapping",
            "!Cidr sequence",
            "!Ref scalar",
            "!Ref mapping",
            "!Ref sequence",
            "!Sub scalar",
            "!Sub mapping",
            "!Sub sequence",
            "!GetAtt scalar",
            "!GetAtt mapping",
            "!GetAtt sequence",
            "!GetAZs scalar",
            "!GetAZs mapping",
            "!GetAZs sequence",
            "!ImportValue scalar",
            "!ImportValue mapping",
            "!ImportValue sequence",
            "!Select scalar",
            "!Select mapping",
            "!Select sequence",
            "!Split scalar",
            "!Split mapping",
            "!Split sequence",
            "!Join scalar",
            "!Join mapping",
            "!Join sequence",
            "!Condition scalar",
            "!Condition mapping",
            "!Condition sequence"
          ],
          "schemas": {
            "https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json": "template.yml"
          }
        }
      }
    }
  }

But it's not working yet
Captura de Tela 2024-09-19 às 14 14 24

Zed: v0.154.0 (Zed Preview)
OS: macOS 15.0.0
Memory: 16 GiB
Architecture: aarch64

@notpeter
Copy link
Member

notpeter commented Sep 19, 2024

Here is an example project that works for me Zed Preview v0.154.0
https://github.com/notpeter2/zed-yaml-example

Unrelated, there's a typo in your settings: s/"!FindInMap mappping",/"!FindInMap mapping",/ (three p's).

@elvishp2006

This comment was marked as resolved.

@notpeter

This comment was marked as resolved.

@elvishp2006
Copy link
Author

I don't know what is happening here:

https://www.youtube.com/watch?v=TuvBA4FqeyI

@notpeter
Copy link
Member

notpeter commented Sep 19, 2024

Can you look in your Zed log ~/Library/Logs/Zed/Zed.log and see if there's anything of note?

It's a little baroque, but from the Command Palette (cmd-shift-p) there's also debug: open language server logs and then you can select "yaml-language-server" and [x] "RPC Messages"
Screenshot 2024-09-19 at 14 19 10

Then if you open the .zed/settings.json and make a change (e.g. add a space and save) you can see the log of communication between Zed and the LSP. Similarly, any actions you perform in the file (edit, hover diagnostics, etc) should show up there too.

I don't have any great ideas about what to look for, but maybe something will pop out at you.

Also worth commenting out any lines in your Zed user settings (`~/.config/zed/settings.json) related to this in case there's some conflict between the user settings and the workspace settings in the repo.

@notpeter notpeter reopened this Sep 19, 2024
@elvishp2006
Copy link
Author

I did commented the section lsp from user settings, and here are the logs:

// Send:
{"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///private/tmp/zed-yaml-example/.zed/settings.json"}}}
// Send:
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"[yaml]":{"editor.tabSize":2},"yaml":{"customTags":["!And scalar","!And mapping","!And sequence","!If scalar","!If mapping","!If sequence","!Not scalar","!Not mapping","!Not sequence","!Equals scalar","!Equals mapping","!Equals sequence","!Or scalar","!Or mapping","!Or sequence","!FindInMap scalar","!FindInMap mapping","!FindInMap sequence","!Base64 scalar","!Base64 mapping","!Base64 sequence","!Cidr scalar","!Cidr mapping","!Cidr sequence","!Ref scalar","!Ref mapping","!Ref sequence","!Sub scalar","!Sub mapping","!Sub sequence","!GetAtt scalar","!GetAtt mapping","!GetAtt sequence","!GetAZs scalar","!GetAZs mapping","!GetAZs sequence","!ImportValue scalar","!ImportValue mapping","!ImportValue sequence","!Select scalar","!Select mapping","!Select sequence","!Split scalar","!Split mapping","!Split sequence","!Join scalar","!Join mapping","!Join sequence","!Condition scalar","!Condition mapping","!Condition sequence"],"schemas":{"https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json":"template.yml"}}}}}
// Receive:
{"jsonrpc":"2.0","id":3,"method":"workspace/configuration","params":{"items":[{"section":"yaml"},{"section":"http"},{"section":"[yaml]"},{"section":"editor"},{"section":"files"}]}}
// Send:
{"jsonrpc":"2.0","id":3,"result":[{"customTags":["!And scalar","!And mapping","!And sequence","!If scalar","!If mapping","!If sequence","!Not scalar","!Not mapping","!Not sequence","!Equals scalar","!Equals mapping","!Equals sequence","!Or scalar","!Or mapping","!Or sequence","!FindInMap scalar","!FindInMap mapping","!FindInMap sequence","!Base64 scalar","!Base64 mapping","!Base64 sequence","!Cidr scalar","!Cidr mapping","!Cidr sequence","!Ref scalar","!Ref mapping","!Ref sequence","!Sub scalar","!Sub mapping","!Sub sequence","!GetAtt scalar","!GetAtt mapping","!GetAtt sequence","!GetAZs scalar","!GetAZs mapping","!GetAZs sequence","!ImportValue scalar","!ImportValue mapping","!ImportValue sequence","!Select scalar","!Select mapping","!Select sequence","!Split scalar","!Split mapping","!Split sequence","!Join scalar","!Join mapping","!Join sequence","!Condition scalar","!Condition mapping","!Condition sequence"],"schemas":{"https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json":"template.yml"}},null,{"editor.tabSize":2},null,null]}
// Receive:
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///private/tmp/zed-yaml-example/template.yml","diagnostics":[{"range":{"start":{"line":15,"character":29},"end":{"line":15,"character":53}},"message":"Incorrect type. Expected \"object(AWS CloudFormation Serverless Application Model (SAM))\".","severity":1,"code":0,"source":"yaml-schema: AWS CloudFormation Serverless Application Model (SAM)","data":{"schemaUri":["https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json"]}}]}}
// Send:
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///private/tmp/zed-yaml-example/template.yml","version":2},"contentChanges":[{"range":{"start":{"line":12,"character":18},"end":{"line":12,"character":18}},"text":" "}]}}
// Send:
{"jsonrpc":"2.0","id":6,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///private/tmp/zed-yaml-example/template.yml"},"position":{"line":12,"character":19},"context":{"triggerKind":2,"triggerCharacter":" "}}}
// Receive:
{"jsonrpc":"2.0","id":6,"result":{"items":[{"kind":12,"label":"!And","insertText":"!And ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!And "}},{"kind":12,"label":"!If","insertText":"!If ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!If "}},{"kind":12,"label":"!Not","insertText":"!Not ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Not "}},{"kind":12,"label":"!Equals","insertText":"!Equals ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Equals "}},{"kind":12,"label":"!Or","insertText":"!Or ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Or "}},{"kind":12,"label":"!FindInMap","insertText":"!FindInMap ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!FindInMap "}},{"kind":12,"label":"!Base64","insertText":"!Base64 ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Base64 "}},{"kind":12,"label":"!Cidr","insertText":"!Cidr ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Cidr "}},{"kind":12,"label":"!Ref","insertText":"!Ref ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Ref "}},{"kind":12,"label":"!Sub","insertText":"!Sub ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Sub "}},{"kind":12,"label":"!GetAtt","insertText":"!GetAtt ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!GetAtt "}},{"kind":12,"label":"!GetAZs","insertText":"!GetAZs ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!GetAZs "}},{"kind":12,"label":"!ImportValue","insertText":"!ImportValue ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!ImportValue "}},{"kind":12,"label":"!Select","insertText":"!Select ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Select "}},{"kind":12,"label":"!Split","insertText":"!Split ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Split "}},{"kind":12,"label":"!Join","insertText":"!Join ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Join "}},{"kind":12,"label":"!Condition","insertText":"!Condition ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Condition "}}],"isIncomplete":false}}
// Receive:
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///private/tmp/zed-yaml-example/template.yml","diagnostics":[{"range":{"start":{"line":15,"character":29},"end":{"line":15,"character":53}},"message":"Incorrect type. Expected \"object(AWS CloudFormation Serverless Application Model (SAM))\".","severity":1,"code":0,"source":"yaml-schema: AWS CloudFormation Serverless Application Model (SAM)","data":{"schemaUri":["https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json"]}}]}}
// Send:
{"jsonrpc":"2.0","id":7,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///private/tmp/zed-yaml-example/template.yml"},"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"context":{"diagnostics":[],"only":["","quickfix","refactor","refactor.extract","source"]}}}
// Receive:
{"jsonrpc":"2.0","id":7,"result":[]}
// Send:
{"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///private/tmp/zed-yaml-example/template.yml"}}}
// Send:
{"jsonrpc":"2.0","id":8,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///private/tmp/zed-yaml-example/template.yml"},"range":{"start":{"line":7,"character":16},"end":{"line":7,"character":16}},"context":{"diagnostics":[],"only":["","quickfix","refactor","refactor.extract","source"]}}}
// Receive:
{"jsonrpc":"2.0","id":8,"result":[]}

@notpeter
Copy link
Member

For anyone we attempts to reproduce this, I still get a single squiggle (which I think is legit) but the youtube video above shows the previous broken behavior.
Screenshot 2024-09-19 at 17 16 28
Screenshot 2024-09-19 at 17 19 19

@adamhake
Copy link

adamhake commented Oct 8, 2024

I also continue to get "Unresolved tag" errors. I experience it in my own SAM projects, and in the above-provided test from @elvishp2006 . I'm running Zed Version: 0.155.2.

Screenshot 2024-10-08 at 15 01 06

my (local) settings:

// Folder-specific settings
//
// For a full list of overridable settings, and general information on folder-specific settings,
// see the documentation: https://zed.dev/docs/configuring-zed#settings-files
{
  "lsp": {
    "yaml-language-server": {
      "settings": {
        "yaml": {
          "customTags": [
            "!And scalar",
            "!And mapping",
            "!And sequence",
            "!If scalar",
            "!If mapping",
            "!If sequence",
            "!Not scalar",
            "!Not mapping",
            "!Not sequence",
            "!Equals scalar",
            "!Equals mapping",
            "!Equals sequence",
            "!Or scalar",
            "!Or mapping",
            "!Or sequence",
            "!FindInMap scalar",
            "!FindInMap mappping",
            "!FindInMap sequence",
            "!Base64 scalar",
            "!Base64 mapping",
            "!Base64 sequence",
            "!Cidr scalar",
            "!Cidr mapping",
            "!Cidr sequence",
            "!Ref scalar",
            "!Ref mapping",
            "!Ref sequence",
            "!Sub scalar",
            "!Sub mapping",
            "!Sub sequence",
            "!GetAtt scalar",
            "!GetAtt mapping",
            "!GetAtt sequence",
            "!GetAZs scalar",
            "!GetAZs mapping",
            "!GetAZs sequence",
            "!ImportValue scalar",
            "!ImportValue mapping",
            "!ImportValue sequence",
            "!Select scalar",
            "!Select mapping",
            "!Select sequence",
            "!Split scalar",
            "!Split mapping",
            "!Split sequence",
            "!Join scalar",
            "!Join mapping",
            "!Join sequence",
            "!Condition scalar",
            "!Condition mapping",
            "!Condition sequence"
          ],
          "schemas": {
            "https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json": "template.yml"
          }
        }
      }
    }
  }
}

@mcsakoff
Copy link

That doesn't look like language server issue.
Here is my minimal project:

.zed/settings.json:

{
  "lsp": {
    "yaml-language-server": {
      "settings": {
        "yaml": {
          "customTags": [
            "!tag1 scalar"
          ]
        }
      }
    }
  }
}

test.yaml:

value_with_know_tag: !tag1 ""
value_with_unknow_tag: !tag2 ""

!tag2 has both warning and error. The error comes from language server (can be found in RPC log).
!tag1 is know by the language server and there is no error for it.

image

@github-actions github-actions bot added admin read Pending admin review triage Maintainer needs to classify the issue labels Nov 5, 2024
@notpeter notpeter removed the triage Maintainer needs to classify the issue label Nov 5, 2024
@notpeter notpeter removed the admin read Pending admin review label Nov 5, 2024
@adamhake
Copy link

adamhake commented Dec 3, 2024

@mcsakoff, I am seeing the same behavior on my end. It does seem like the language server picks up the custom tags. However, when I disable the language server entirely via the languages.YAML.enable_language_server setting, both the errors and warnings disappear. This leads me to believe that the warnings are generated by the language server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] language server An umbrella label for all language servers regression A bug that was introduced in a recent release yaml YAML data format support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants