{"record":{"id":"04bcb61fe2d42f5a","repo":"shadowsocks/shadowsocks-rust","slug":"missing-locals-for-client-configuration","errorCode":null,"errorMessage":"missing `locals` for client configuration","messagePattern":"missing `locals` for client configuration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/shadowsocks-service/src/config.rs","lineNumber":2853,"sourceCode":"    }\n\n    /// Check if there are any plugin are enabled with servers\n    pub fn has_server_plugins(&self) -> bool {\n        for inst in &self.server {\n            let server = &inst.config;\n\n            if server.plugin().is_some() {\n                return true;\n            }\n        }\n        false\n    }\n\n    /// Check if all required fields are already set\n    pub fn check_integrity(&self) -> Result<(), Error> {\n        if self.config_type.is_local() {\n            if self.local.is_empty() {\n                let err = Error::new(\n                    ErrorKind::MissingField,\n                    \"missing `locals` for client configuration\",\n                    None,\n                );\n                return Err(err);\n            }\n\n            for local_config in &self.local {\n                local_config.config.check_integrity()?;\n            }\n\n            // Balancer related checks\n            if let Some(rtt) = self.balancer.max_server_rtt\n                && rtt.as_secs() == 0\n            {\n                let err = Error::new(ErrorKind::Invalid, \"balancer.max_server_rtt must be > 0\", None);\n                return Err(err);\n            }","sourceCodeStart":2835,"sourceCodeEnd":2871,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/crates/shadowsocks-service/src/config.rs#L2835-L2871","documentation":"ServiceConfig::check_integrity verifies that all fields required for the configured config_type are present. When config_type is a local (client) type but the locals list is empty, this Error with ErrorKind::MissingField is returned: a shadowsocks client needs at least one local listener to serve.","triggerScenarios":"Calling check_integrity() on a client-type Config after loading/compiling, with Config.local empty — e.g. a config JSON that only sets server addresses and method/password but defines no local listeners (locals array empty or absent).","commonSituations":"Using a server config file with a client binary (sslocal), copying a config template that omits the locals section, or programmatically constructing Config without pushing entries into local.","solutions":["Add at least one entry to the locals array in the config (e.g. a socks5 or http listener with address and port).","Ensure you are running the client (sslocal) with a client config, not the server config file.","If building Config in code, call config.local.push(LocalConfig::new(...)) before check_integrity().","Verify config_type is set to Local and matches the binary you are launching."],"exampleFix":"// before\n{ \"locals\": [] }\n// after\n{ \"locals\": [ { \"type\": \"socks\", \"addr\": \"127.0.0.1\", \"port\": 1080 } ] }","handlingStrategy":"validation","validationCode":"fn validate_client_config(cfg: &Config) -> Result<(), String> {\n    if cfg.config_type.is_local() && cfg.local.is_empty() {\n        return Err(\"client config requires at least one entry in 'locals'\".into());\n    }\n    Ok(())\n}","typeGuard":"fn has_local_listeners(cfg: &Config) -> bool {\n    !cfg.config_type.is_local() || !cfg.local.is_empty()\n}","tryCatchPattern":"match service_config.check_integrity() {\n    Ok(()) => { /* start client */ }\n    Err(e) if e.to_string().contains(\"missing `locals`\") => {\n        log::error!(\"client config has no locals: add a socks/http listener\");\n    }\n    Err(e) => log::error!(\"config integrity check failed: {e}\"),\n}","preventionTips":["Always define at least one local listener (socks/http) for client (sslocal) configs","Do not reuse a server (ssserver) config file for the client binary","Validate the config JSON schema before loading it in production","Run check_integrity() early in your own code with a clear error message"],"tags":["config","client","validation","shadowsocks"],"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"}