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

Misleading information example #24

Closed
supertong opened this issue Aug 8, 2018 · 3 comments
Closed

Misleading information example #24

supertong opened this issue Aug 8, 2018 · 3 comments
Assignees
Labels
Milestone

Comments

@supertong
Copy link
Contributor

Example input:

{
  "version": 1,
  "type": "doc",
  "content": [
    {
      "type": "paragraph",
      "content": [
        {
          "type": "text",
          "text": "test"
        }
      ]
    },
    {
      "type": "mediaSingle",
      "attrs": {
        "layout": "wide"
      },
      "content": [
        {
          "type": "media",
          "attrs": {
            "id": "cfb55f7b-68be-42ac-9930-216f754805a1",
            "type": "file",
            "collection": "",
            "occurrenceKey": null,
            "width": null
          }
        }
      ]
    },
    {
      "type": "paragraph",
      "content": [
        {
          "type": "text",
          "text": " "
        }
      ]
    }
  ]
}

and the error message is

{
    "message": "Document field document JSON doesn't comply with Atlassian Document Format Full",
    "meta": {
        "errors": [
            {
                "start": {
                    "line": 1,
                    "column": 109,
                    "offset": 108
                },
                "end": {
                    "line": 1,
                    "column": 122,
                    "offset": 121
                },
                "error": "/content/1/type should be equal to one of the allowed values: orderedList, heading, panel, table, decisionList, taskList, bodiedExtension, codeBlock",
                "suggestion": "Did you mean heading?"
            }
        ]
    },
    "status": 400
}

But the error was actually inside the mediaNode under mediaSingle.

@torifat torifat added the bug label Aug 20, 2018
@zanedev
Copy link

zanedev commented Sep 3, 2019

We're seeing this a lot where the error is very misleading, showing an unrelated error at the top of a nested $ref when the problem is actually in the $ref children somewhere.

@torifat torifat added this to the v1.0 milestone Sep 9, 2019
@torifat torifat self-assigned this Sep 9, 2019
@torifat
Copy link
Collaborator

torifat commented Sep 10, 2019

@zanedev The whole thing works based on some heuristics. Because in some cases it's really difficult to find the exact error. It would make my life easier if you could share some examples where it doesn't work.

@torifat
Copy link
Collaborator

torifat commented Sep 10, 2019

@supertong ajv returns the following error for this case 🤦‍♂

[
    {
      keyword: 'additionalProperties',
      dataPath: '/content/1',
      schemaPath: '#/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties'
    },
    {
      keyword: 'additionalProperties',
      dataPath: '/content/1',
      schemaPath: '#/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties'
    },
    {
      keyword: 'additionalProperties',
      dataPath: '/content/1',
      schemaPath: '#/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties'
    },
    {
      keyword: 'additionalProperties',
      dataPath: '/content/1',
      schemaPath: '#/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties'
    },
    {
      keyword: 'type',
      dataPath: '/content/1/content/0/attrs/width',
      schemaPath: '#/definitions/media_node/properties/attrs/anyOf/0/properties/width/type',
      params: [Object],
      message: 'should be number'
    },
    {
      keyword: 'additionalProperties',
      dataPath: '/content/1/content/0/attrs',
      schemaPath: '#/definitions/media_node/properties/attrs/anyOf/1/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties'
    },
    {
      keyword: 'anyOf',
      dataPath: '/content/1/content/0/attrs',
      schemaPath: '#/definitions/media_node/properties/attrs/anyOf',
      params: {},
      message: 'should match some schema in anyOf'
    },
    {
      keyword: 'enum',
      dataPath: '/content/1/type',
      schemaPath: '#/properties/type/enum',
      params: [Object],
      message: 'should be equal to one of the allowed values'
    },
    {
      keyword: 'enum',
      dataPath: '/content/1/type',
      schemaPath: '#/properties/type/enum',
      params: [Object],
      message: 'should be equal to one of the allowed values'
    },
    {
      keyword: 'enum',
      dataPath: '/content/1/type',
      schemaPath: '#/properties/type/enum',
      params: [Object],
      message: 'should be equal to one of the allowed values'
    },
    {
      keyword: 'enum',
      dataPath: '/content/1/type',
      schemaPath: '#/properties/type/enum',
      params: [Object],
      message: 'should be equal to one of the allowed values'
    },
    {
      keyword: 'enum',
      dataPath: '/content/1/type',
      schemaPath: '#/properties/type/enum',
      params: [Object],
      message: 'should be equal to one of the allowed values'
    },
    {
      keyword: 'enum',
      dataPath: '/content/1/type',
      schemaPath: '#/properties/type/enum',
      params: [Object],
      message: 'should be equal to one of the allowed values'
    },
    {
      keyword: 'enum',
      dataPath: '/content/1/type',
      schemaPath: '#/properties/type/enum',
      params: [Object],
      message: 'should be equal to one of the allowed values'
    },
    {
      keyword: 'additionalProperties',
      dataPath: '/content/1',
      schemaPath: '#/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties'
    },
    {
      keyword: 'additionalProperties',
      dataPath: '/content/1',
      schemaPath: '#/definitions/rule_node/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties'
    },
    {
      keyword: 'additionalProperties',
      dataPath: '/content/1',
      schemaPath: '#/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties'
    },
    {
      keyword: 'additionalProperties',
      dataPath: '/content/1',
      schemaPath: '#/definitions/applicationCard_node/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties'
    },
    {
      keyword: 'enum',
      dataPath: '/content/1/type',
      schemaPath: '#/properties/type/enum',
      params: [Object],
      message: 'should be equal to one of the allowed values'
    },
    {
      keyword: 'enum',
      dataPath: '/content/1/type',
      schemaPath: '#/properties/type/enum',
      params: [Object],
      message: 'should be equal to one of the allowed values'
    },
    {
      keyword: 'enum',
      dataPath: '/content/1/type',
      schemaPath: '#/properties/type/enum',
      params: [Object],
      message: 'should be equal to one of the allowed values'
    },
    {
      keyword: 'additionalProperties',
      dataPath: '/content/1',
      schemaPath: '#/definitions/extension_node/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties'
    },
    {
      keyword: 'enum',
      dataPath: '/content/1/type',
      schemaPath: '#/properties/type/enum',
      params: [Object],
      message: 'should be equal to one of the allowed values'
    },
    {
      keyword: 'additionalProperties',
      dataPath: '/content/1',
      schemaPath: '#/definitions/blockCard_node/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties'
    },
    {
      keyword: 'additionalProperties',
      dataPath: '/content/1',
      schemaPath: '#/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties'
    },
    {
      keyword: 'anyOf',
      dataPath: '/content/1',
      schemaPath: '#/properties/content/items/anyOf',
      params: {},
      message: 'should match some schema in anyOf'
    }
  ]

torifat added a commit to torifat/better-ajv-errors that referenced this issue Sep 10, 2019
torifat added a commit to torifat/better-ajv-errors that referenced this issue Sep 10, 2019
torifat added a commit to torifat/better-ajv-errors that referenced this issue Sep 10, 2019
torifat added a commit to torifat/better-ajv-errors that referenced this issue Sep 10, 2019
torifat added a commit to torifat/better-ajv-errors that referenced this issue Sep 10, 2019
torifat added a commit to torifat/better-ajv-errors that referenced this issue Sep 10, 2019
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