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

Closed
wants to merge 4 commits into 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?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is for now. But it won't be needed when we have full support for inline config.

@yash-atreya yash-atreya enabled auto-merge (squash) November 22, 2024 06:53
@yash-atreya
Copy link
Member Author

@grandizzy can we merge this?

@yash-atreya yash-atreya self-assigned this Nov 25, 2024
@yash-atreya
Copy link
Member Author

Superseded by #9414

auto-merge was automatically disabled November 27, 2024 06:23

Pull request was closed

@yash-atreya yash-atreya removed their assignment Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

bug: inline config not catching some errors
4 participants