{"record":{"id":"1a5ee8dfb73354f3","repo":"shadowsocks/shadowsocks-rust","slug":"invalid-replay-attack-policy","errorCode":null,"errorMessage":"invalid replay attack policy","messagePattern":"invalid replay attack policy","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/shadowsocks-service/src/config.rs","lineNumber":2631,"sourceCode":"        if let Some(b) = config.inbound_udp_allow_fragmentation {\n            nconfig.inbound_udp_allow_fragmentation = b;\n        }\n\n        if let Some(proxy_config) = config.outbound_proxy {\n            nconfig.outbound_proxy = proxy_config\n                .into_proxies()\n                .map_err(|e| Error::new(ErrorKind::Invalid, \"invalid outbound_proxy\", Some(e)))?;\n        }\n\n        // Security\n        if let Some(sec) = config.security\n            && let Some(replay_attack) = sec.replay_attack\n            && let Some(policy) = replay_attack.policy\n        {\n            match policy.parse::<ReplayAttackPolicy>() {\n                Ok(p) => nconfig.security.replay_attack.policy = p,\n                Err(..) => {\n                    let err = Error::new(ErrorKind::Invalid, \"invalid replay attack policy\", None);\n                    return Err(err);\n                }\n            }\n        }\n\n        if let Some(balancer) = config.balancer {\n            nconfig.balancer = BalancerConfig {\n                max_server_rtt: balancer.max_server_rtt.map(Duration::from_secs),\n                check_interval: balancer.check_interval.map(Duration::from_secs),\n                check_best_interval: balancer.check_best_interval.map(Duration::from_secs),\n            };\n        }\n\n        if let Some(acl_path) = config.acl {\n            let acl = match AccessControl::load_from_file(&acl_path) {\n                Ok(acl) => acl,\n                Err(err) => {\n                    let err = Error::new(","sourceCodeStart":2613,"sourceCodeEnd":2649,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/crates/shadowsocks-service/src/config.rs#L2613-L2649","documentation":"When a Config declares security.replay_attack.policy, the string is parsed into a ReplayAttackPolicy enum during config compilation. If parse::<ReplayAttackPolicy>() fails, this Error with ErrorKind::Invalid is returned. It means the replay-attack policy name in the configuration is not one of the recognized policy values.","triggerScenarios":"Config field security.replay_attack.policy set to a string that does not parse as a ReplayAttackPolicy (e.g. misspelled or unknown policy name) while building ServiceConfig at crates/shadowsocks-service/src/config.rs:2631.","commonSituations":"Hand-editing the JSON config and writing policy: \"disabled\" or \"enable\" instead of the exact accepted values (e.g. \"none\", \"lru\", \"bloom\" depending on features), or copying config from an older/newer version with different policy names.","solutions":["Set security.replay_attack.policy to one of the exact accepted values (see ReplayAttackPolicy::from_str).","Omit security.replay_attack.policy to use the default policy.","Check the crate version's supported policy names; they can differ between releases.","Enable the relevant cargo feature (e.g. replay attack detection) if the policy enum variant is feature-gated."],"exampleFix":"// before\n\"security\": { \"replay_attack\": { \"policy\": \"disable\" } }\n// after\n\"security\": { \"replay_attack\": { \"policy\": \"lru\" } }","handlingStrategy":"validation","validationCode":"fn validate_replay_policy(v: &str) -> Result<(), String> {\n    match v {\n        \"none\" | \"lru\" | \"bloom\" => Ok(()),\n        other => Err(format!(\"unknown replay_attack.policy: {other}\")),\n    }\n}","typeGuard":"fn is_known_replay_policy(v: &str) -> bool {\n    matches!(v, \"none\" | \"lru\" | \"bloom\")\n}","tryCatchPattern":"match config.security.as_ref().and_then(|s| s.replay_attack.as_ref()).and_then(|r| r.policy.as_deref()) {\n    Some(p) => match p.parse::<ReplayAttackPolicy>() {\n        Ok(_) => {}\n        Err(_) => log::error!(\"replay_attack.policy '{p}' is invalid; use an accepted policy name\"),\n    },\n    None => {}\n}","preventionTips":["Copy policy names exactly from the crate docs/examples, never from memory","Omit the policy field to accept the library default","Re-check accepted values when upgrading shadowsocks versions"],"tags":["config","security","replay-attack","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"}