{"record":{"id":"921456abeae12f54","repo":"neondatabase/neon","slug":"invalid-format-s-a-valid-example-is-attached","errorCode":null,"errorMessage":"Invalid format '{s}', a valid example is 'attached:1'","messagePattern":"Invalid format '(.+?)', a valid example is 'attached:1'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"control_plane/storcon_cli/src/main.rs","lineNumber":357,"sourceCode":"    command: Command,\n}\n\n#[derive(Debug, Clone)]\nstruct PlacementPolicyArg(PlacementPolicy);\n\nimpl FromStr for PlacementPolicyArg {\n    type Err = anyhow::Error;\n\n    fn from_str(s: &str) -> Result<Self, Self::Err> {\n        match s {\n            \"detached\" => Ok(Self(PlacementPolicy::Detached)),\n            \"secondary\" => Ok(Self(PlacementPolicy::Secondary)),\n            _ if s.starts_with(\"attached:\") => {\n                let mut splitter = s.split(':');\n                let _prefix = splitter.next().unwrap();\n                match splitter.next().and_then(|s| s.parse::<usize>().ok()) {\n                    Some(n) => Ok(Self(PlacementPolicy::Attached(n))),\n                    None => Err(anyhow::anyhow!(\n                        \"Invalid format '{s}', a valid example is 'attached:1'\"\n                    )),\n                }\n            }\n            _ => Err(anyhow::anyhow!(\n                \"Unknown placement policy '{s}', try detached,secondary,attached:<n>\"\n            )),\n        }\n    }\n}\n\n#[derive(Debug, Clone)]\nstruct SkSchedulingPolicyArg(SkSchedulingPolicy);\n\nimpl FromStr for SkSchedulingPolicyArg {\n    type Err = anyhow::Error;\n\n    fn from_str(s: &str) -> Result<Self, Self::Err> {","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/neondatabase/neon/blob/8f60b04da47ffefe0e52bda2440134b42874eb75/control_plane/storcon_cli/src/main.rs#L339-L375","documentation":"storcon_cli parses placement policy arguments via FromStr: only 'detached', 'secondary', or 'attached:<n>' with n an unsigned integer are accepted. This error fires when the value starts with 'attached:' but the remainder does not parse as usize.","triggerScenarios":"Passing attached: (empty suffix), attached:one, attached:-1, attached:1.5, or attached:0x2 — the prefix matches but the suffix fails usize::from_str.","commonSituations":"Scripts building the flag from variables that may be empty or non-numeric, copy-pasting documentation placeholders into commands.","solutions":["Use a non-negative integer after the colon, e.g. attached:1","Quote/escape the argument so the shell does not mangle it","Validate the value in the calling script before invoking the CLI"],"exampleFix":"# before\n--placement-policy attached:one\n# after\n--placement-policy attached:1","handlingStrategy":"type-guard","validationCode":"fn parse_placement(s: &str) -> Result<PlacementPolicyArg, String> {\n    s.parse().map_err(|e| format!(\"{e}; expected detached|secondary|attached:<usize>\"))\n}","typeGuard":"fn is_valid_placement_policy(s: &str) -> bool {\n    if matches!(s, \"detached\" | \"secondary\") { return true; }\n    let mut parts = s.split(':');\n    parts.next() == Some(\"attached\")\n        && parts.next().map(|n| n.parse::<usize>().is_ok()).unwrap_or(false)\n        && parts.next().is_none()\n}","tryCatchPattern":null,"preventionTips":["Validate the flag in wrapper scripts before invoking storcon_cli","Generate the value from an integer variable instead of free text","Use shell completion to avoid typos"],"tags":["rust","storcon-cli","cli","argument-parsing","placement-policy"],"backgroundTag":"invalid-cli-argument","analyzedSha":"8f60b04da47ffefe0e52bda2440134b42874eb75","analyzedAt":"2026-08-16T23:39:28.135Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}