{"record":{"id":"d25e236bbc21d4c9","repo":"shadowsocks/shadowsocks-rust","slug":"method-is-required-d25e23","errorCode":null,"errorMessage":"`method` is required","messagePattern":"`method` is required","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/service/local.rs","lineNumber":634,"sourceCode":"            }\n            None => {\n                logging::init_with_config(\"sslocal\", &service_config.log);\n            }\n        }\n\n        trace!(\"{:?}\", service_config);\n\n        let mut config = match config_path_opt {\n            Some(cpath) => Config::load_from_file(&cpath, ConfigType::Local)\n                .map_err(|err| ShadowsocksError::LoadConfigFailure(format!(\"loading config {cpath:?}, {err}\")))?,\n            None => Config::new(ConfigType::Local),\n        };\n\n        if let Some(svr_addr) = matches.get_one::<String>(\"SERVER_ADDR\") {\n            let method = matches\n                .get_one::<String>(\"ENCRYPT_METHOD\")\n                .map(|x| x.parse::<CipherKind>().expect(\"method\"))\n                .expect(\"`method` is required\");\n\n            let password = match matches.get_one::<String>(\"PASSWORD\") {\n                Some(pwd) => read_variable_field_value(pwd).into(),\n                None => {\n                    // NOTE: svr_addr should have been checked by crate::vparser\n                    if method.is_none() {\n                        // If method doesn't need a key (none, plain), then we can leave it empty\n                        String::new()\n                    } else {\n                        match crate::password::read_server_password(svr_addr) {\n                            Ok(pwd) => pwd,\n                            Err(..) => panic!(\"`password` is required for server {svr_addr}\"),\n                        }\n                    }\n                }\n            };\n\n            let svr_addr = svr_addr.parse::<ServerAddr>().expect(\"server-addr\");","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/src/service/local.rs#L616-L652","documentation":"Same branch as error 173: when SERVER_ADDR is provided, the code insists ENCRYPT_METHOD exists via .expect(\"`method` is required\"). A per-server cipher is mandatory to construct ServerConfig, so a missing method aborts the process. clap's validation normally prevents this; the expect is a backstop.","triggerScenarios":"Running sslocal with SERVER_ADDR set but no --encrypt-method flag, or calling local::create programmatically with ArgMatches lacking ENCRYPT_METHOD.","commonSituations":"Command lines copied from AEAD-free examples; scripts that drop the method flag when SERVER_ADDR is set; hand-built ArgMatches in tests.","solutions":["Add --encrypt-method <cipher> (e.g. aes-256-gcm) whenever a SERVER_ADDR is specified.","Use a config file (-c) that includes a server entry with its own \"method\" field.","If invoking create programmatically, supply \"ENCRYPT_METHOD\" in the matches."],"exampleFix":"// before\nsslocal -b 127.0.0.1:1080 -s example.com:8388 -k secret\n\n// after\nsslocal -b 127.0.0.1:1080 -s example.com:8388 -k secret --encrypt-method aes-256-gcm","handlingStrategy":"validation","validationCode":"if matches.get_one::<String>(\"SERVER_ADDR\").is_some()\n    && matches.get_one::<String>(\"ENCRYPT_METHOD\").is_none()\n{\n    return Err(\"--encrypt-method is required when SERVER_ADDR is given\".into());\n}","typeGuard":null,"tryCatchPattern":"let Some(s) = matches.get_one::<String>(\"ENCRYPT_METHOD\") else {\n    eprintln!(\"`method` is required\");\n    return ExitCode::FAILURE;\n};","preventionTips":["Use -c config.json with per-server \"method\" fields instead of CLI-only setups.","Add a launcher-script check that --encrypt-method is present whenever -s is used.","Document required flag pairings in deployment runbooks."],"tags":["cli","rust","missing-argument","panic"],"backgroundTag":"missing-required-argument","analyzedSha":"8eb0f0a65b1d976ab6bed5787327ef86529b0435","analyzedAt":"2026-09-09T12:20:43.168Z","contentChangedAt":"2026-09-09T12:20:43.168Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}