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

Should this format work? #50

Open
mrchief opened this issue Mar 22, 2020 · 3 comments
Open

Should this format work? #50

mrchief opened this issue Mar 22, 2020 · 3 comments

Comments

@mrchief
Copy link

mrchief commented Mar 22, 2020

Given this error log:

FAILURE: Schema [/github/workspace/schemas/meta-info/jsonschema/1-0-0] contains following errors:
1. error: "objecta" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])
    level: "error"
    domain: "syntax"
    schema: {"loadingURI":"#","pointer":""}
    keyword: "type"
    found: "objecta"
    valid: ["array","boolean","integer","null","number","object","string"]

2. Error: JSON Schema [iglu:root/meta-info/jsonschema/1-0-0] doesn't conform path [schemas/meta-info/jsonschema/1-0-0]
FAILURE: Schema [/github/workspace/schemas/view_info/jsonschema/1-0-0] contains following errors:
1. Error: JSON Schema [iglu:root/view_info/jsonschema/1-0-0] doesn't conform path [schemas/view_info/jsonschema/1-0-0]
FAILURE: Schema [/github/workspace/schemas/page_info/jsonschema/1-0-0] contains following errors:
1. error: "String" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])
    level: "error"
    domain: "syntax"
    schema: {"loadingURI":"#","pointer":"/properties/page_access"}
    keyword: "type"
    found: "String"
    valid: ["array","boolean","integer","null","number","object","string"]

2. Error: JSON Schema [iglu:root/page_info/jsonschema/1-0-0] doesn't conform path [schemas/page_info/jsonschema/1-0-0]
FAILURE: Schema [/github/workspace/schemas/user_info/jsonschema/1-0-0] contains following errors:
1. Error: JSON Schema [iglu:root/user_info/jsonschema/1-0-0] doesn't conform path [schemas/user_info/jsonschema/1-0-0]
TOTAL: 0 Schemas were successfully validated
TOTAL: 4 invalid Schemas were encountered
TOTAL: 6 errors were encountered

and errorformat string

%EFAILURE:\ Schema\ [%-P%f]%.%#,%#.\ %m,%C%.%#,%-G%.%#

the playground can parse errors correctly

[
  {
    "filename": "/github/workspace/schemas/meta-info/jsonschema/1-0-0",
    "lnum": 0,
    "col": 0,
    "vcol": false,
    "nr": 0,
    "pattern": "",
    "text": "error: \"objecta\" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])",
    "type": 0,
    "valid": true,
    "lines": [
      "1. error: \"objecta\" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])"
    ]
  },
  {
    "filename": "/github/workspace/schemas/meta-info/jsonschema/1-0-0",
    "lnum": 0,
    "col": 0,
    "vcol": false,
    "nr": 0,
    "pattern": "",
    "text": "Error: JSON Schema [iglu:root/meta-info/jsonschema/1-0-0] doesn't conform path [schemas/meta-info/jsonschema/1-0-0]",
    "type": 0,
    "valid": true,
    "lines": [
      "2. Error: JSON Schema [iglu:root/meta-info/jsonschema/1-0-0] doesn't conform path [schemas/meta-info/jsonschema/1-0-0]"
    ]
  },
  {
    "filename": "/github/workspace/schemas/view_info/jsonschema/1-0-0",
    "lnum": 0,
    "col": 0,
    "vcol": false,
    "nr": 0,
    "pattern": "",
    "text": "Error: JSON Schema [iglu:root/view_info/jsonschema/1-0-0] doesn't conform path [schemas/view_info/jsonschema/1-0-0]",
    "type": 0,
    "valid": true,
    "lines": [
      "1. Error: JSON Schema [iglu:root/view_info/jsonschema/1-0-0] doesn't conform path [schemas/view_info/jsonschema/1-0-0]"
    ]
  },
  {
    "filename": "/github/workspace/schemas/page_info/jsonschema/1-0-0",
    "lnum": 0,
    "col": 0,
    "vcol": false,
    "nr": 0,
    "pattern": "",
    "text": "error: \"String\" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])",
    "type": 0,
    "valid": true,
    "lines": [
      "1. error: \"String\" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])"
    ]
  },
  {
    "filename": "/github/workspace/schemas/page_info/jsonschema/1-0-0",
    "lnum": 0,
    "col": 0,
    "vcol": false,
    "nr": 0,
    "pattern": "",
    "text": "Error: JSON Schema [iglu:root/page_info/jsonschema/1-0-0] doesn't conform path [schemas/page_info/jsonschema/1-0-0]",
    "type": 0,
    "valid": true,
    "lines": [
      "2. Error: JSON Schema [iglu:root/page_info/jsonschema/1-0-0] doesn't conform path [schemas/page_info/jsonschema/1-0-0]"
    ]
  },
  {
    "filename": "/github/workspace/schemas/user_info/jsonschema/1-0-0",
    "lnum": 0,
    "col": 0,
    "vcol": false,
    "nr": 0,
    "pattern": "",
    "text": "Error: JSON Schema [iglu:root/user_info/jsonschema/1-0-0] doesn't conform path [schemas/user_info/jsonschema/1-0-0]",
    "type": 0,
    "valid": true,
    "lines": [
      "1. Error: JSON Schema [iglu:root/user_info/jsonschema/1-0-0] doesn't conform path [schemas/user_info/jsonschema/1-0-0]"
    ]
  }
]

But the CLI tool

cat err.log | errorformat '%EFAILURE:\ Schema\ [%-P%f]%.%#,%#.\ %m,%C%.%#,%-G%.%#'  

doesn't output the filename properly:

|| FAILURE: Schema [/github/workspace/schemas/meta-info/jsonschema/1-0-0] contains following errors:
|| 1. error: "objecta" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])
||     level: "error"
||     domain: "syntax"
||     schema: {"loadingURI":"#","pointer":""}
||     keyword: "type"
||     found: "objecta"
||     valid: ["array","boolean","integer","null","number","object","string"]
||
|| 2. Error: JSON Schema [iglu:root/meta-info/jsonschema/1-0-0] doesn't conform path [schemas/meta-info/jsonschema/1-0-0]
|| FAILURE: Schema [/github/workspace/schemas/view_info/jsonschema/1-0-0] contains following errors:
|| 1. Error: JSON Schema [iglu:root/view_info/jsonschema/1-0-0] doesn't conform path [schemas/view_info/jsonschema/1-0-0]  
|| FAILURE: Schema [/github/workspace/schemas/page_info/jsonschema/1-0-0] contains following errors:
|| 1. error: "String" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])
||     level: "error"
||     domain: "syntax"
||     schema: {"loadingURI":"#","pointer":"/properties/page_access"}
||     keyword: "type"
||     found: "String"
||     valid: ["array","boolean","integer","null","number","object","string"]
||
|| 2. Error: JSON Schema [iglu:root/page_info/jsonschema/1-0-0] doesn't conform path [schemas/page_info/jsonschema/1-0-0]
|| FAILURE: Schema [/github/workspace/schemas/user_info/jsonschema/1-0-0] contains following errors:
|| 1. Error: JSON Schema [iglu:root/user_info/jsonschema/1-0-0] doesn't conform path [schemas/user_info/jsonschema/1-0-0]
|| TOTAL: 0 Schemas were successfully validated
|| TOTAL: 4 invalid Schemas were encountered
|| TOTAL: 6 errors were encountered

README says ...but it doesn't support Vim regex. but I see this too

efm, _ := errorformat.NewErrorformat([]string{`%f:%l:%c: %m`, `%-G%.%#`})

which is using a regex pattern %.%#.

Not a vim user and up until yesterday, I had no idea what an errorformat was. So I'm not sure what's going on here.

The ultimate issue is that reviewdog is not reporting any findings despite errors so I'm trying to debug that.

@mrchief mrchief changed the title Should this format work Should this format work? Mar 22, 2020
@vk26
Copy link
Contributor

vk26 commented Mar 30, 2020

Try to separate formats via whitespace:

cat issue | errorformat "%EFAILURE:\ Schema\ [%-P%f]%.%#" "%#.\ %m" "%C%.%#" "%-G%.%#"
/github/workspace/schemas/meta-info/jsonschema/1-0-0|| error: "objecta" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])
/github/workspace/schemas/meta-info/jsonschema/1-0-0|| Error: JSON Schema [iglu:root/meta-info/jsonschema/1-0-0] doesn't conform path [schemas/meta-info/jsonschema/1-0-0]
/github/workspace/schemas/view_info/jsonschema/1-0-0|| Error: JSON Schema [iglu:root/view_info/jsonschema/1-0-0] doesn't conform path [schemas/view_info/jsonschema/1-0-0]
/github/workspace/schemas/page_info/jsonschema/1-0-0|| error: "String" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])
/github/workspace/schemas/page_info/jsonschema/1-0-0|| Error: JSON Schema [iglu:root/page_info/jsonschema/1-0-0] doesn't conform path [schemas/page_info/jsonschema/1-0-0]
/github/workspace/schemas/user_info/jsonschema/1-0-0|| Error: JSON Schema [iglu:root/user_info/jsonschema/1-0-0] doesn't conform path [schemas/user_info/jsonschema/1-0-0]

@vk26
Copy link
Contributor

vk26 commented Mar 30, 2020

And if you pass -efm flag for reviewdog, you have to pass multiple efm flag in this case:

reviewdog -efm="%EFAILURE:\ Schema\ [%-P%f]%.%#" -efm="%#.\ %m" -efm="%C%.%#" -efm="%-G%.%#"

@mrchief
Copy link
Author

mrchief commented Mar 31, 2020

Ah I see! I wanted to incorporate reviewdog with my action https://github.com/marketplace/actions/iglu-schema-lint but I couldn't due to this issue. I resorted to doing regex matches.

Another issue I ran into was the fact that these errors didn't have a line number all the time, so again I'm trying to guess them in order to make sure they are part of diff. Is that something reviewdog can handle better?

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

No branches or pull requests

2 participants