cli validate - better messages with filenames and line numbers when validating the configuration #23008
Labels
domain: config
Anything related to configuring Vector
domain: validation
type: feature
A value-adding code addition that introduce new functionality.
A note for the community
Use Cases
When using the command
vector validate
there are 2 types of errors that are too generic and lacking in information : when validating the basic structure of the configuration files (not the parameters, but the format itself), and when parsing a directory of multiple files.Such situations cause the error message being too generic without indicating neither :
See after for concrete examples.
Attempted Solutions
1st case : validity of the file structure
To reproduce, take the default vector.yaml file provided with the deb or rpm file, get the
sinks
section and remove the sub-elements to keep only the section header :The error is not surprising as vector does not accept an empty sinks declaration, but the problem is, there are no information about the line, context or anything helping to understand.
If possible the line number, or at least the section name currently validated would help (here, "sinks")
2nd case : the filename being the source of the error
Same situation, but change the command line to add
--config-dir /etc/vector/vector.d
and throw in a bunch of yaml files.You'll get this result :
Even if the error provides the line number or the ID name causing the error, there will be no information about the filename itself.
In the case of the validity of the format (the valid TOML error), as no real information is given, it can take a while to find the file, as vector specify that it loaded everything in the message "Failed to load ..."
bonus case : "TOML" message for a YAML file
It was surprising at first, seeing the message
expected any valid TOML value
while using only YAML files.No real harm, still.
Proposal
My suggestion is that for each error the
validate
command can return, it should, in all case, print :This is partially done with the type.custom_id printed when in error, but it is not constant with all errors
References
Didn't see much, but maybe my search-fu is not good enough.
Version
vector v0.46.1
The text was updated successfully, but these errors were encountered: