syzkaller
syzkaller copied to clipboard
pkg/mgrconfig: report line and column on parse config error
Is your feature request related to a problem? Please describe.
Example error message when there is error in syz manager cfg file:
failed to parse config file: invalid character ']' looking for beginning of value
Not very informative, could be better.
Describe the solution you'd like
Something like this:
failed to parse config file: invalid character ']' looking for beginning of value at <line>:<col>
***also source line maybe***
That would be nice, indeed.
But it would not be a one-line fix unfortunately.
-
We remove comments before parsing the JSON, which must be accounted for https://github.com/google/syzkaller/blob/77908e5f2ae80bee6d434bca762a25a0a5fc6a83/pkg/config/config.go#L28-L29
-
Go's json library only points at the offset from the beginning of the input data, it doesn't care about line numbers https://pkg.go.dev/encoding/json#SyntaxError
Maybe consider using hjson format (it has comment support) and it also accepts normal json.
Haven't used it though, not sure if their error information is better.
Or perhaps YAML.