{"record":{"id":"c73d64db4c1f80ff","repo":"shadowsocks/shadowsocks-rust","slug":"password-is-required-for-server-svr-addr","errorCode":null,"errorMessage":"`password` is required for server {svr_addr}","messagePattern":"`password` is required for server (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/service/local.rs","lineNumber":646,"sourceCode":"        };\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\");\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            }","sourceCodeStart":628,"sourceCodeEnd":664,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/src/service/local.rs#L628-L664","documentation":"When building local server config from CLI (`sslocal --server-addr ...`), if the chosen method needs a key (not none/plain) and the password cannot be read (e.g. not provided via CLI/env and the encrypted-password read fails), create() panics. The library requires a non-empty password for any keyed cipher. It is fail-fast configuration validation.","triggerScenarios":"Calling public `LocalConfig/Service create` (from main) for each `--server-addr` entry when `read_server_password(svr_addr)` returns Err and a cipher method requiring a key is set.","commonSituations":"Running `sslocal --server-addr host:port --encrypt-method aes-256-gcm` without `--password`; password stored in an encrypted/env source that is unavailable; typo in password env variable name.","solutions":["Pass the password explicitly: add `--password <pwd>` to the sslocal command line","Set the expected password environment variable (PASSWORD or per-server password env)","Use method `none`/`plain` only for testing when no password is intended","If using encrypted password files, fix the key/env so read_server_password succeeds"],"exampleFix":"// before\nsslocal --server-addr example.com:8388 --encrypt-method aes-256-gcm\n// after\nsslocal --server-addr example.com:8388 --encrypt-method aes-256-gcm --password s3cret","handlingStrategy":"validation","validationCode":"# fail early with a clear message before invoking sslocal:\n[ -n \"$PASSWORD\" ] || { echo 'PASSWORD is required for keyed ciphers'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --password (or the password env) when using keyed cipher methods","Keep method/password pairs together in deployment templates","Use method `none`/`plain` only intentionally for testing","Verify encrypted-password source availability before launch"],"tags":["panic","cli","configuration","password"],"backgroundTag":"missing-required-config-field","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"}