syzkaller icon indicating copy to clipboard operation
syzkaller copied to clipboard

pkg/mgrconfig: report line and column on parse config error

Open Slava0135 opened this issue 6 months ago • 3 comments

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***

Slava0135 avatar May 09 '25 18:05 Slava0135

That would be nice, indeed.

But it would not be a one-line fix unfortunately.

  1. 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

  2. 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

a-nogikh avatar May 12 '25 07:05 a-nogikh

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.

https://github.com/hjson/hjson-go

Slava0135 avatar May 12 '25 07:05 Slava0135

Or perhaps YAML.

dvyukov avatar May 12 '25 08:05 dvyukov