yaml extension error ( Incorrect type. Expected "string".yaml-schema: pubspec.yaml )

1,022

Solution 1

Please update VSCode's YAML extension to at least 1.5.1 to resolve the error. Flutter will work as it is with the errors too.

Solution 2

I'm having the same issue with VSCode since this afternoon, everything worked well before. I've tried forcing the schema via # yaml-language-server: $schema=<urlToTheSchema> and yaml.schemas setting, but no luck.

Edit: could be related to upgrading to yaml extension v1.5.0 (cf: https://github.com/redhat-developer/vscode-yaml/issues/708) Temporarily downgrading back to 1.4.0 no longer throws errors.

Solution 3

The YAML extension is using an incorrect schema to validate your YAML file. Ensure that:

  • your file does contain a correct # yaml-language-server: $schema=<urlToTheSchema> comment or at least does not contain a wrong one.
  • your yaml.schemas setting does not associate your file via glob pattern with an incorrect schema.

The correct schema would be https://json.schemastore.org/pubspec.json. See also Associating Schemas.

Solution 4

I reload the YAML extension and the error gone

Share:
1,022
Jinto Joseph
Author by

Jinto Joseph

just a simple human , nothing more , nothing less .......

Updated on January 03, 2023

Comments

  • Jinto Joseph
    Jinto Joseph over 1 year

    enter image description here

    Recently i created a flutter project and open the "YAML" ,getting some error from "YAML" extension , How can i solve this , is the only solution uninstall the extension or how to overcome this without uninstalling this extension

    tried flutter clean , repair etc..... but nothing was helpful ,

    getting error are

    1 Incorrect type. Expected "string".yaml-schema: pubspec.yaml

    2 Property flutter is not allowed.yaml-schema: pubspec.yaml

    3 Property cupertino_icons is not allowed.yaml-schema: pubspec.yaml

    4 Property flutter_test is not allowed.yaml-schema: pubspec.yaml

    5 ect........

    using flutter version is 2.8.1

    "YAML"(extension) version v1.5.0

    • Massimo Caroccia
      Massimo Caroccia about 2 years
      I've the same problem
    • YeN
      YeN about 2 years
      same problem too
    • Tokenizer
      Tokenizer about 2 years
      Same issue here.
  • Jinto Joseph
    Jinto Joseph about 2 years
    i'm also downgrade the extension to 1.4.0 ,working fine . it's temporary solutions ,i think new version has some schema issue ,