Skip to content

Enum arrays always give "Value is not accepted" error even when the document is valid #1188

Description

@wiktor-k

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

  1. Paste my example YAML into a new file.
  2. Observe the issue.

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)

Extension version: 1.19.1

Thanks for your work, this extension is invaluable 🙇

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions