redhat-developer / redhat-developer/vscode-yaml

UnhandledPromiseRejectionWarning: TypeError: Cannot create property 'url' on string 'string'

Open
#603 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
829
Forks
260
Avg merge
5h 43m
Merged PRs (30d)
1

Description

Describe the bug

When I am editing a YAML file with my custom schema, it validates properly and gives me an error highlight once, but when I fix the error, the highlight never goes away. When I look at the message log, I see a traceback:

[Error - 9:17:30 PM] (node:96798) UnhandledPromiseRejectionWarning: TypeError: Cannot create property 'url' on string 'string'
    at _validateObjectNode (/Users/pprescod/.vscode/extensions/redhat.vscode-yaml-0.22.0/node_modules/yaml-language-server/out/server/src/languageservice/parser/jsonParser07.js:983:44)
    at validate (/Users/pprescod/.vscode/extensions/redhat.vscode-yaml-0.22.0/node_modules/yaml-language-server/out/server/src/languageservice/parser/jsonParser07.js:438:13)
    at _validateArrayNode (/Users/pprescod/.vscode/extensions/redhat.vscode-yaml-0.22.0/node_modules/yaml-language-server/out/server/src/languageservice/parser/jsonParser07.js:843:21)
    at validate (/Users/pprescod/.vscode/extensions/redhat.vscode-yaml-0.22.0/node_modules/yaml-language-server/out/server/src/languageservice/parser/jsonParser07.js:441:13)
    at SingleYAMLDocument.validate (/Users/pprescod/.vscode/extensions/redhat.vscode-yaml-0.22.0/node_modules/yaml-language-server/out/server/src/languageservice/parser/jsonParser07.js:398:13)
    at getDiagnostics (/Users/pprescod/.vscode/extensions/redhat.vscode-yaml-0.22.0/node_modules/vscode-json-languageservice/lib/umd/services/jsonValidation.js:69:59)
    at /Users/pprescod/.vscode/extensions/redhat.vscode-yaml-0.22.0/node_modules/vscode-json-languageservice/lib/umd/services/jsonValidation.js:106:24

jsonParser07.js line 983 is

propertySchema.url = (_a = schema.url) !== null && _a !== void 0 ? _a : originalSchema.url;

Expected Behavior

Errors should change as I edit my file. No tracebacks.

Steps to Reproduce

  1. Create this Schema file:
{
    "$id": "https://github.com/SFDO-Tooling/Snowfakery/schema/snowfakery_recipe.schema.json",
    "description": "Snowfakery recipe.",
    "type": "array",
    "minItems": 1
}

  1. Create a related Schema

yaml-language-server: $schema=file:snowfakery_recipe.schema.json

  • object: fooboffsef
    fields:
    foo: bar
  1. Change the file URL to be appropriate for your setup.

  2. Try changing - object: fooboffsef to - objectxxx: fooboffsef to get a validation error.

  3. Change it back.

Environment

  • Windows
  • [ X] Mac
  • Linux
  • other (please specify)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the YAML-schema edit cycle and trace validation through jsonParser07.js, especially _validateObjectNode, _validateArrayNode, and SingleYAMLDocument.validate around the reported line. Confirm that changing the invalid property back no longer produces an UnhandledPromiseRejectionWarning and that diagnostics update correctly without a stale highlight.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode, yaml
Domain
devtools, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.