-
Notifications
You must be signed in to change notification settings - Fork 363
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
bug(rust): CLI argument parser doesn't work for some configurations. #2662
Comments
I think i found the reason. hyperlane-monorepo/rust/hyperlane-base/src/settings/chains.rs Lines 89 to 95 in d88fd4c
So this issue is not only affecting to |
I can reproduce this issue with the following code snippet use serde_json;
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct TestHyperlaneArgParse {
single: Option<String>,
camel_case_upper: Option<String>,
camel_case_lower: Option<String>,
snake_case_upper: Option<String>,
snake_case_lower: Option<String>,
}
fn main() {
let json_data = r#"
{
"single": "single",
"camelCaseUpper": "camel_case_upper",
"camelcaselower": "camel_case_lower",
"snake_Case_Upper": "snake_case_upper",
"snake_case_lower": "snake_case_lower"
}
"#;
let deserialized: Result<TestHyperlaneArgParse, serde_json::Error> = serde_json::from_str(json_data);
match deserialized {
Ok(data) => {
println!("{:?}", data);
},
Err(err) => {
println!("Error: {:?}", err);
}
}
} Its output is TestHyperlaneArgParse { single: Some("single"), camel_case_upper: Some("camel_case_upper"), camel_case_lower: None, snake_case_upper: None, snake_case_lower: None }
|
Can you elaborate on what "Not parsed correctly means". The argument parser was intentionally designed to lowercase the strings to be insensitive to either the literal |
Wait, okay, I see, the issue is that you are not able to specify the core contract address via arg due to casing issues. I think this reasonably slipped through testing because to the best of my knowledge we have always specified this via config file. |
yes, the problem is that the parser does lower-case while obj deserializer uses camelCase. |
As a stop gap I recommend creating a config file using your helm chart. What we do internally is we ship the docker image with the chains config you see in the repo; this means our helm files don't need to generate the config file. |
This bug might block the planned changes in #2215 |
yeap, thanks for your suggestion |
### Description This is a fix for an issue in the arguments and environment where we are unable to correctly support attribute names due to the casing. The main issue cannot be fully fixed practically by this PR because it would cause some configuration cases to break. For now it adds manual exceptions for the command line argument case and leaves envs as they were. There are then two new parsers that can be used with the new config format. ### Drive-by changes Also adds this to argument parser since it was trivial to copy/paste it and it will allow us to harden parsing when we switch over. ### Related issues - Fixes #2662 - Fixes #2663 - Progress on #2215 ### Backward compatibility Yes ### Testing Unit Tests
The following configurations are not parsed from either env var or cli args.Configurations whose key includes multiple words are not parsed from CLI args correctly. Here are typical ones.(edited)
Btw, when I use a config file, it works.
Here is a discord link for more details https://discord.com/channels/935678348330434570/984123861144600587/1139906822510219284
The text was updated successfully, but these errors were encountered: