{"record":{"id":"91baf49debd82a92","repo":"ducaale/xh","slug":"is-not-a-valid-value","errorCode":null,"errorMessage":"{:?} is not a valid value","messagePattern":"(.+?) is not a valid value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli.rs","lineNumber":1173,"sourceCode":"}\n\nimpl FromStr for Print {\n    type Err = anyhow::Error;\n    fn from_str(s: &str) -> anyhow::Result<Print> {\n        let mut request_headers = false;\n        let mut request_body = false;\n        let mut response_headers = false;\n        let mut response_body = false;\n        let mut response_meta = false;\n\n        for char in s.chars() {\n            match char {\n                'H' => request_headers = true,\n                'B' => request_body = true,\n                'h' => response_headers = true,\n                'b' => response_body = true,\n                'm' => response_meta = true,\n                char => return Err(anyhow!(\"{:?} is not a valid value\", char)),\n            }\n        }\n\n        let p = Print {\n            request_headers,\n            request_body,\n            response_headers,\n            response_body,\n            response_meta,\n        };\n        Ok(p)\n    }\n}\n\n#[derive(Debug, Clone)]\npub struct Timeout(Duration);\n\nimpl Timeout {","sourceCodeStart":1155,"sourceCodeEnd":1191,"githubUrl":"https://github.com/ducaale/xh/blob/2404aceecc08b0b2d100fedc96f57745cd5904dc/src/cli.rs#L1155-L1191","documentation":"The -p/--print value parser accepts only the characters H, B, h, b, m (request headers/body, response headers/body/meta). Any other character in the print specifier returns this anyhow error naming the offending char.","triggerScenarios":"Passing -p or --print with a character outside {H,B,h,b,m}, e.g. -pHx or -phdr.","commonSituations":"Typos in the print spec; confusion with curl-style flags; scripts copying print strings between tools.","solutions":["Use only the letters H B h b m in the print specifier (e.g. -p hb for response body+headers)","Remove invalid characters from the -p argument","Check `http --help` for the documented print spec characters"],"exampleFix":"# before\nhttp -p Hx GET example.org\n# after\nhttp -p hB GET example.org","handlingStrategy":"validation","validationCode":"// validate the print spec before invoking\nfn valid_print(spec: &str) -> bool {\n    !spec.is_empty() && spec.chars().all(|c| matches!(c, 'H'|'B'|'h'|'b'|'m'))\n}\nassert!(valid_print(&print_spec));","typeGuard":"fn is_print_spec(s: &str) -> bool { s.chars().all(|c| \"HBhbm\".contains(c)) && !s.is_empty() }","tryCatchPattern":"let out = Command::new(\"http\").args([\"-p\", &print_spec, \"GET\", url]).output()?;\nif !out.status.success() && String::from_utf8_lossy(&out.stderr).contains(\"is not a valid value\") {\n    eprintln!(\"invalid -p spec '{print_spec}': use only H B h b m\");\n}","preventionTips":["Use only H B h b m characters in -p/--print","Default to -p hb or omit -p entirely","Validate user-supplied print specs in scripts"],"tags":["cli","print","parsing"],"backgroundTag":"invalid-argument-value","analyzedSha":"2404aceecc08b0b2d100fedc96f57745cd5904dc","analyzedAt":"2026-09-13T19:13:33.814Z","contentChangedAt":"2026-09-13T19:13:33.814Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}