You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when the analyzer is used through go vet, if no config flag is provided or the provided path is invalid, the analyzer produces this error message:
levee: failed prerequisites: fieldtags, source
This message does not provide any hints as to its cause, which will likely leave users scratching their head. (I know I've scratched my own head more than once when dealing with this issue.)
Additional context
If the config can't be read, the fieldtags and source analyzers will fail:
Then, in the analysis package, running levee fails because its dependencies failed:
// Report an error if any dependency failed.varfailed []stringfor_, dep:=rangeact.deps {
ifdep.err!=nil {
failed=append(failed, dep.String())
}
}
iffailed!=nil {
sort.Strings(failed)
act.err=fmt.Errorf("failed prerequisites: %s", strings.Join(failed, ", "))
return
}
Note that when the analyzer is run directly (i.e. not through go vet), the error message is much better:
error reading analysis config: open config.yaml: no such file or directory
This message may still be a bit confusing to users who did not specify a config at all. The open config.yaml part is due to the fact that the config flag defaults to config.yaml.
The text was updated successfully, but these errors were encountered:
[Just spreading knowledge from some brief fix attempts.]
I was poking at this issue and thought the most obvious solution would be to add a config.ReadConfig() check in the cmd/levee/ before the analyzer even got going. Unfortunately, that also produces very strange results when used with go vet -vettool=....
Failing fast would be preferable to failing once per package / analyzer, but if we're not able to do that before the analyzer gets rolling, we could perhaps read config in a base "analyzer" and percolate errors up that way. I'd kind of hate how that would look, though.
[edit:] Actually, I just stubbed that shim analyzer approach out and it's not any better. We still end up spending all the cycles build buildssa, and since the error would still be an wrapped in an upstream analyzer anyway, it doesn't report any cleaner. It of course just adds one more to the meaningless set of levee: failed prerequisites: config, fieldtags, source. So that's a wash too. Probably should've seen that coming.
Thank you for doing this investigation! I'm surprised that the shim analyzer approach didn't work, but it makes sense in retrospect.
I think one way to at least show the error message would be to print it to the terminal in the code that reads the config, but then there would be duplicate messages when the analyzer is run by itself. That may be a reasonable tradeoff, though.
Currently, when the analyzer is used through
go vet
, if noconfig
flag is provided or the provided path is invalid, the analyzer produces this error message:This message does not provide any hints as to its cause, which will likely leave users scratching their head. (I know I've scratched my own head more than once when dealing with this issue.)
Additional context
If the config can't be read, the
fieldtags
andsource
analyzers will fail:Then, in the
analysis
package, runninglevee
fails because its dependencies failed:Note that when the analyzer is run directly (i.e. not through
go vet
), the error message is much better:This message may still be a bit confusing to users who did not specify a
config
at all. Theopen config.yaml
part is due to the fact that theconfig
flag defaults toconfig.yaml
.The text was updated successfully, but these errors were encountered: