{"record":{"id":"4ff52ccc0a1d84c2","repo":"shadowsocks/shadowsocks-rust","slug":"malformed-plugin-mode-must-be-one-of-tcp-only","errorCode":null,"errorMessage":"malformed `plugin_mode`, must be one of `tcp_only`, `udp_only` and `tcp_and_udp`","messagePattern":"malformed `plugin_mode`, must be one of `tcp_only`, `udp_only` and `tcp_and_udp`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/shadowsocks-service/src/config.rs","lineNumber":2205,"sourceCode":"                    }\n                };\n                nsvr.set_source(server_source);\n                nsvr.set_mode(global_mode);\n\n                if let Some(ref p) = config.plugin {\n                    // SIP008 allows \"plugin\" to be an empty string\n                    // Empty string implies \"no plugin\"\n                    if !p.is_empty() {\n                        let plugin = PluginConfig {\n                            plugin: p.clone(),\n                            plugin_opts: config.plugin_opts.clone(),\n                            plugin_args: config.plugin_args.clone().unwrap_or_default(),\n                            plugin_mode: match config.plugin_mode {\n                                None => Mode::TcpOnly,\n                                Some(ref mode) => match mode.parse::<Mode>() {\n                                    Ok(m) => m,\n                                    Err(..) => {\n                                        let e = Error::new(\n                                            ErrorKind::Malformed,\n                                            \"malformed `plugin_mode`, must be one of `tcp_only`, `udp_only` and `tcp_and_udp`\",\n                                            None,\n                                        );\n                                        return Err(e);\n                                    }\n                                },\n                            },\n                        };\n                        nsvr.set_plugin(plugin);\n                    }\n                }\n\n                if let Some(timeout) = config.timeout.map(Duration::from_secs) {\n                    nsvr.set_timeout(timeout);\n                }\n\n                nconfig.server.push(ServerInstanceConfig::with_server_config(nsvr));","sourceCodeStart":2187,"sourceCodeEnd":2223,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/crates/shadowsocks-service/src/config.rs#L2187-L2223","documentation":"Thrown when parsing a server entry with a plugin: the `plugin_mode` string cannot be parsed into a Mode. Only `tcp_only`, `udp_only`, and `tcp_and_udp` are accepted; anything else yields ErrorKind::Malformed.","triggerScenarios":"Config parsing where `plugin_mode` is set to an unrecognized value: misspellings like `tcp`, `TCP`, `tcp+udp`, `both`, or translated labels from other tools.","commonSituations":"Converting configs from other shadowsocks GUIs that use different plugin-mode spellings; typos; leaving a placeholder value in the JSON.","solutions":["Set plugin_mode to exactly one of `tcp_only`, `udp_only`, or `tcp_and_udp`","Remove the `plugin_mode` field if the default (TcpOnly) is acceptable","Check case: values must be lowercase as listed"],"exampleFix":"// before\n{\"plugin\": \"v2ray-plugin\", \"plugin_mode\": \"tcp+udp\"}\n// after\n{\"plugin\": \"v2ray-plugin\", \"plugin_mode\": \"tcp_and_udp\"}","handlingStrategy":"validation","validationCode":"const MODES: &[&str] = &[\"tcp_only\", \"udp_only\", \"tcp_and_udp\"];\n// before load: if let Some(m) = obj.get(\"plugin_mode\") { assert!(MODES.contains(&m.as_str().unwrap_or(\"\"))); }","typeGuard":null,"tryCatchPattern":"match mode_str.parse::<shadowsocks::config::Mode>() {\n    Ok(m) => m,\n    Err(_) => { eprintln!(\"plugin_mode must be tcp_only|udp_only|tcp_and_udp\"); return; }\n}","preventionTips":["Only use the three documented mode strings verbatim","Omit plugin_mode to get the TcpOnly default","Normalize modes when importing configs from other tools"],"tags":["plugin","config","enum"],"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-14T16:17:12.679Z"}