{"record":{"id":"089f30355ad59d3c","repo":"shadowsocks/shadowsocks-rust","slug":"method-089f30","errorCode":null,"errorMessage":"method","messagePattern":"method","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/service/server.rs","lineNumber":336,"sourceCode":"                logging::init_with_file(path);\n            }\n            None => {\n                logging::init_with_config(\"ssserver\", &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::Server)\n                .map_err(|err| ShadowsocksError::LoadConfigFailure(format!(\"loading config {cpath:?}, {err}\")))?,\n            None => Config::new(ConfigType::Server),\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","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/src/service/server.rs#L318-L354","documentation":"In the server service `create`, the `ENCRYPT_METHOD` CLI value is parsed with `x.parse::<CipherKind>().expect(\"method\")`. The panic means the provided encryption method string is not a valid `CipherKind`. This occurs while constructing a server from `--server-addr` CLI arguments (rather than a config file).","triggerScenarios":"Running `ssserver` with `--encrypt-method` set to an unrecognized cipher name — legacy ciphers (e.g. `aes-256-cfb`), wrong casing, extra whitespace, or a cipher not enabled in the build's feature flags.","commonSituations":"Following outdated tutorials referencing stream ciphers; mismatched method strings shared between client and server; typo in long cipher names like `2022-blake3-aes-128-gcm`.","solutions":["Use an exact supported cipher: `aes-256-gcm`, `aes-128-gcm`, `chacha20-ietf-poly1305`, or SIP002 `2022-*` ciphers","Keep the method string identical on both client and server","Enable the required cargo feature if the cipher was compiled out","Put the method in the config file instead of CLI to avoid quoting/casing issues"],"exampleFix":"// before\n--encrypt-method rc4-md5\n// after\n--encrypt-method chacha20-ietf-poly1305","handlingStrategy":"validation","validationCode":"const VALID: &[&str] = &[\"aes-128-gcm\",\"aes-256-gcm\",\"chacha20-ietf-poly1305\"];\nif let Some(m) = &cli.method {\n    assert!(VALID.contains(&m.as_str()), \"unknown method {m}\");\n}","typeGuard":"fn is_known_cipher(s: &str) -> bool {\n    matches!(s, \"aes-128-gcm\" | \"aes-256-gcm\" | \"chacha20-ietf-poly1305\")\n}","tryCatchPattern":"// parse with a clear message\nlet kind: CipherKind = m.parse().map_err(|_| anyhow!(\"unsupported --encrypt-method {m}\"))?;","preventionTips":["Standardize on AEAD cipher names across deployments","Validate flags in wrapper scripts before exec","Match casing exactly: all lowercase"],"tags":["cli","encryption","parsing","shadowsocks"],"backgroundTag":"invalid-enum-value","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"}