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

oneOf: misleading validation failures with Incorrect type. Expected "object" #692

Closed
ssbarnea opened this issue Feb 4, 2022 · 3 comments
Assignees
Labels
Milestone

Comments

@ssbarnea
Copy link
Member

ssbarnea commented Feb 4, 2022

Describe the bug

I discovered that the error message on invalidated values does only report the first failed check, even if the field allows multiple variants, confusing the user about which measures he can do.

# .github/workflows/sample.yml
jobs:
  foo:
    steps:
       - run: echo 123
      env: ${{ matrix.env }} # <-- line that should fail validation

As github-workflows schema requires either an object for env or a string following a specific pattern, that line should produce a validation error as the pattern does not match current string.

# relevant section from schema:
"oneOf": [
        {
          "type": "object",
          "additionalProperties": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "minProperties": 1
        },
        {
          "$ref": "#/definitions/expressionSyntax",
          "$comment": "https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson",
          "pattern": "^\\$\\{\\{\\s*fromJSON\\(.*\\)\\s*\\}\\}$"
        }
      ]
    },

Expected Behavior

Display a validation message that mentions that oneOf multiple conditions needs to be met, so the user can figure-out what he did wrong.

Current Behavior

As you can see the error below is incomplete and is misleading the user about not accepting strings.

Incorrect type. Expected "object".
@evidolob evidolob added the bug label Feb 4, 2022
@evidolob evidolob added this to the 1.5.0 milestone Feb 4, 2022
@ssbarnea
Copy link
Member Author

ssbarnea commented Feb 4, 2022

Not sure if that is the same bug or another one so I will only mention it as a comment first.

Apparently keys under matrix: in github workflows are marked as not allowed, even if the schema is correctly defined.

Look at https://github.com/SchemaStore/schemastore/blob/master/src/test/github-workflow/matrix_include.json#L13-L22 test file, which raise false positive with us.

The schema files used is the one at https://json.schemastore.org/github-workflow.json

@ssbarnea
Copy link
Member Author

ssbarnea commented Mar 4, 2022

I suspect that #691 (comment) is not working for the same reasons. When we will see a new release?... or where can I download a build from master so I can check if this was fixed.

@msivasubramaniaan
Copy link
Contributor

@ssbarnea The new release would be coming week. will let you know with the release details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants