errorformat
errorformat copied to clipboard
Should this format work?
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.
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]
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%.%#"
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?