{"record":{"id":"77470f81ca008d79","repo":"shadowsocks/shadowsocks-rust","slug":"failed-to-create-serverconfig-error","errorCode":null,"errorMessage":"failed to create ServerConfig, error: {}","messagePattern":"failed to create ServerConfig, error: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/service/local.rs","lineNumber":658,"sourceCode":"                    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\");\n            let timeout = matches.get_one::<u64>(\"TIMEOUT\").map(|x| Duration::from_secs(*x));\n\n            let mut sc = match ServerConfig::new(svr_addr, password, method) {\n                Ok(sc) => sc,\n                Err(err) => {\n                    panic!(\"failed to create ServerConfig, error: {}\", err);\n                }\n            };\n            sc.set_source(ServerSource::CommandLine);\n            if let Some(timeout) = timeout {\n                sc.set_timeout(timeout);\n            }\n\n            if let Some(p) = matches.get_one::<String>(\"PLUGIN\").cloned() {\n                let plugin = PluginConfig {\n                    plugin: p,\n                    plugin_opts: matches.get_one::<String>(\"PLUGIN_OPT\").cloned(),\n                    plugin_args: Vec::new(),\n                    plugin_mode: matches\n                        .get_one::<String>(\"PLUGIN_MODE\")\n                        .map(|x| {\n                            x.parse::<Mode>()\n                                .expect(\"plugin-mode must be one of `tcp_only` (default), `udp_only` and `tcp_and_udp`\")\n                        })","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/src/service/local.rs#L640-L676","documentation":"After parsing address and password, create() constructs a ServerConfig with ServerConfig::new(svr_addr, password, method) and panics if construction fails. ServerConfig::new rejects invalid combinations such as unsupported method names or invalid server address types for the method. The embedded `err` carries the precise reason.","triggerScenarios":"Calling public `create` (from main) while iterating CLI `--server-addr` entries; `ServerConfig::new` returns Err, e.g. because the method string is not a recognized cipher kind or the addr/format is inconsistent with the method (e.g. non-2022 format password for an AEAD-2022 method).","commonSituations":"Misspelled cipher method (`aes-256-gcm ` with trailing space, `chacha20-ietf-poly1305` unavailable under disabled features); AEAD-2022 methods given a base64 password of wrong length; method names differing between CLI and JSON config syntax.","solutions":["Read the embedded error message for the exact ServerConfig validation failure","Use a valid method name supported by the build (check --help / feature flags)","For 2022 methods, supply a correctly sized base64 key (e.g. openssl rand -base64 32)","Verify the server-addr format: `host:port` or `[ipv6]:port`"],"exampleFix":"// before\nsslocal --server-addr example.com:8388 --encrypt-method aes-256-gcmv1 --password s3cret\n// after\nsslocal --server-addr example.com:8388 --encrypt-method aes-256-gcm --password s3cret","handlingStrategy":"validation","validationCode":"# pre-validate method/addr before launch:\necho \"$METHOD\" | grep -Eq '^(aes-128-gcm|aes-256-gcm|chacha20-ietf-poly1305|2022-blake3-aes-256-gcm|none|plain)$' || exit 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy method names exactly from the supported list (--help or docs)","For 2022 ciphers generate base64 keys of the correct length","Test configs with a dry run before production rollout","Keep CLI and JSON-config method spellings consistent"],"tags":["panic","cli","configuration","server-config"],"backgroundTag":"invalid-config-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"}