redhat-developer / redhat-developer/vscode-yaml
Enum arrays always give "Value is not accepted" error even when the document is valid
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 830
- Forks
- 260
- Avg merge
- 5h 43m
- Merged PRs (30d)
- 1
Description
Describe the bug
I'm actually not sure if it's a schema issue but it looks fine. If I'm mistaken, sorry!
It seems the language server doesn't properly support string enum arrays.
I'm using the following schema: https://raw.githubusercontent.com/aquasecurity/trivy/main/schema/trivy-config.json
This fragment is relevant:
"severity": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"UNKNOWN",
"LOW",
"MEDIUM",
"HIGH",
"CRITICAL"
],
"description": "severities of security issues to be displayed"
},
When I use the following fragment in my yaml:
# yaml-language-server: $schema=https://raw.githubusercontent.com/aquasecurity/trivy/main/schema/trivy-config.json
severity:
- MEDIUM
Expected Behavior
No errors happen, since MEDIUM is value in the enum.
Current Behavior
I see the following error: Value is not accepted. Valid values: "UNKNOWN", "LOW", "MEDIUM", "HIGH", "CRITICAL".
Quoting "MEDIUM" or using alternative YAML array syntaxes doesn't work either.
Steps to Reproduce
- Paste my example YAML into a new file.
- Observe the issue.
Environment
- Windows
- Mac
- Linux
- other (please specify)
Extension version: 1.19.1
Thanks for your work, this extension is invaluable 🙇
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostic with the Trivy schema URL and the YAML fragment from the report, then trace the language server's enum validation for arrays. Done means the MEDIUM array value produces no error, with coverage for the reported schema pattern.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, yaml
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100