-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Config validation to build stage to prevent runtime panics #777
Labels
Comments
Seems like this can be taken up! @mway Should I go ahead or this needs prior design discussion? |
@YashishDua Yes, please! If you'd like to take a stab at it, go for it. Thank you! |
abhinav
added a commit
that referenced
this issue
Mar 4, 2020
This adds validation for Level and EncoderConfig.EncoderTime when building a logger from a zap.Config. Resolves #777 Co-authored-by: Abhinav Gupta <abg@uber.com>
cgxxv
pushed a commit
to cgxxv/zap
that referenced
this issue
Mar 25, 2022
This adds validation for Level and EncoderConfig.EncoderTime when building a logger from a zap.Config. Resolves uber-go#777 Co-authored-by: Abhinav Gupta <abg@uber.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When creating a custom zap.Config there seems to be only minimal validation of the configuration that results in runtime panics if certain properties are missing. This is dangerous as all required configuration properties should be checked at the build stage.
There is probably a reason this has not been done, but opening an issue nonetheless.
Example
This results in the following panic:
The issue here is we are missing a "Level"
However, there are other issues as well. Suppose you specify the "TimeKey", but not the "EncodeTime".
This configuration will build without error, but you again will be faced with
runtime error: invalid memory address or nil pointer dereference
on use.The text was updated successfully, but these errors were encountered: