Skip to content
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

fix(forge): detect invalid inline config keys #9363

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

yash-atreya
Copy link
Member

Motivation

Closes #5371

Solution

  • Introduce const VALID_CONFIG_KEYS
  • Parse the config lines and see if it contains any keys that are outside VALID_CONFIG_KEYS.
  • Throw InvalidConfigKey error if it does.

Comment on lines +59 to +65
return Err(InlineConfigError {
line,
source: InlineConfigParserError::InvalidConfigKey(
wrong_key,
format!("{VALID_CONFIG_KEYS:?}"),
),
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a warning would be sufficient here given that the key is simply ignored when continuing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warnings won't be shown if --quiet is enabled.

Moreover, currently we error out on invalid property keys like fuzz.runssss. This keeps it consistent with that i.e err thrown on invalid keys.

Comment on lines +5 to +11
/// Used to detect invalid configuration keys in the inline config.
///
/// # Example
///
/// forge-config: default.fuzz.runs = 100 - `fuzz` is a valid key
/// forge-config: default.wrong.runs = 100 - `wrong` is an invalid key
const VALID_CONFIG_KEYS: [&str; 2] = ["fuzz", "invariant"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now this is sufficient I think, assuming this functionality will be updated when we have full support for in-line configuration

///
/// forge-config: default.fuzz.runs = 100 - `fuzz` is a valid key
/// forge-config: default.wrong.runs = 100 - `wrong` is an invalid key
const VALID_CONFIG_KEYS: [&str; 2] = ["fuzz", "invariant"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this isn't too simplistic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

bug: inline config not catching some errors
4 participants