-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(config): warn on unknown config keys in foundry.toml #10621
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've given you a little feedback 👍
I think it might be nice to implement this verification as a separate helper function.
@zarkk01 this would be really good to have, wonder if you have time time to wrap up the work (accommodate comments and test to check warnings are emitted). thank you! |
Yes, I will wrap it up until the end of the week! :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, left some comments re current impl
|
||
// if we found any, log a single warning with a list | ||
if !ignored.is_empty() { | ||
warn!("Found unknown config keys in {}: {}", Self::FILE_NAME, ignored.join(", ")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should use sh_warn
and output message. We already have collect_warnings so should use that one
pub fn collect_warnings(&self) -> Result<Vec<Warning>, Error> { |
Would be great to address also the inline config, that is #5371
|
||
#[traced_test] | ||
#[test] | ||
fn warn_unknown_keys_logs_warning_for_unknown_keys() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are good but would be great to have an e2e test too where we run forge for a project with unknown config keys defined in foundry.toml and inline and we assert proper warnings displayed
Motivation
closes #10550
Right now, if a user makes a typo or adds a deprecated field in their local
foundry.toml
, Figment/Serde simply ignores it and the user never knows something went unused. That can lead to confusion or misconfiguration.Solution
Before Figment does
.extract()
into theConfig
struct, we readfoundry.toml
as raw TOML, run it through [serde_ignored
] to collect any unused/unknown keys, and if any are found we log awarn!
listing them. This is non-breaking (we still load all the valid settings) and only affects root keys for now.For now, could I have some feedback on the implementation?
PR Checklist