samsung-cnct / jsonsvalidator

JSON Schema Validator
Apache License 2.0
0 stars 2 forks source link

Inconsistent/ambiguous error output on general exceptions (out of our control) #4

Open notjames opened 7 years ago

notjames commented 7 years ago

This issue will need to be fixed in the upstream library used for JSON schema validation and is being tracked here

This does not affect the validity or invalidity of the schema validation, to the best of my knowledge. Simply put, if a general exception occurs, the output from the error bubbled up from the library is vague, ambiguous, and/or inconsistent. From my experience, it stems from an invalid schema or some such.

This is a decent synopsis of the issue, however:

13:02:13-jimconn~/go/src/jsonsvalidator (bugfix-1)$ jsv validate -s /Users/jimconn/go/src/projects/k2-src/k2/schemas/config/v1/config.json -c ~/.kraken/config.yaml | jq '.'
{
  "is_valid": false,
  "exception": [
    {
      "error_string": "format must be a valid format symver",
      "path": "a general exception occurred; probably an invalid schema; see https://github.com/xeipuuv/gojsonschema/issues/160"
    }
  ],
  "config": "/Users/jimconn/.kraken/config.yaml",
  "schema": "/Users/jimconn/go/src/projects/k2-src/k2/schemas/config/v1/config.json"
}
13:10:36-jimconn~/go/src/jsonsvalidator (bugfix-1)$ jsv validate -s /Users/jimconn/go/src/projects/k2-src/k2/schemas/config/v1/config.json -c ~/.kraken/config.yaml | jq '.'
{
  "is_valid": false,
  "exception": [
    {
      "error_string": "format must be a valid format symver",
      "path": "a general exception occurred; probably an invalid schema; see https://github.com/xeipuuv/gojsonschema/issues/160"
    }
  ],
  "config": "/Users/jimconn/.kraken/config.yaml",
  "schema": "/Users/jimconn/go/src/projects/k2-src/k2/schemas/config/v1/config.json"
}
13:10:45-jimconn~/go/src/jsonsvalidator (bugfix-1)$ jsv validate -s /var/tmp/schemas/config/v1/config.json -c ~/.kraken/config.yaml | jq '.'
{
  "is_valid": false,
  "exception": [
    {
      "error_string": "url: url is required",
      "path": "(root).definitions.helmConfigs.0.repos.0"
    },
    {
      "error_string": "url: url is required",
      "path": "(root).definitions.helmConfigs.0.repos.1"
    },
    {
      "error_string": "url: url is required",
      "path": "(root).deployment.clusters.0.helmConfig.repos.0"
    },
    {
      "error_string": "url: url is required",
      "path": "(root).deployment.clusters.0.helmConfig.repos.1"
    },
    {
      "error_string": "basic: basic is required",
      "path": "(root).deployment.clusters.0.kubeAuth.authn"
    }
  ],
  "config": "/Users/jimconn/.kraken/config.yaml",
  "schema": "/var/tmp/schemas/config/v1/config.json"
}

This is simply a tracking ticket for the upstream issue. I don't think there's much we can do about this short of forking the upstream project, fixing it, and submitting a PR.

davidewatson commented 7 years ago

@notjames or @coffeepac: This repo needs labels. https://medium.com/@dtinth/how-to-copy-github-labels-from-one-project-to-another-1857adc73e0f gives a manual process. https://github.com/samsung-cnct/solas/issues/8 was opened to fix this in the future.

coffeepac commented 7 years ago

labels added.

notjames commented 7 years ago

Created gojsonschema PR https://github.com/xeipuuv/gojsonschema/pull/161 which partially addresses ambiguous schema validation errors.