ducaale/xh · error
Unsupported option
Error message
Unsupported option '{key}' What it means
The --format-options parser explicitly rejects the key 'json.sort_keys' as unsupported, even though it follows the dotted key=value syntax. Any other unrecognized key yields the separate 'Unknown option' error.
Solutions
- Remove json.sort_keys from --format-options
- Request the feature upstream or patch cli.rs to implement sorted JSON keys
- Use a post-processing step (e.g. jq -S) to sort JSON output
Example fix
# before http --format-options=json.sort_keys=true GET example.org # after http GET example.org | jq -S .
Defensive patterns
Strategy: validation
Validate before calling
// validate format options before invoking
const SUPPORTED: &[&str] = &["json.format","json.indent","xml.format","xml.indent","headers.sort"];
for kv in opts.split(',') {
let key = kv.split('=').next().unwrap();
if key == "json.sort_keys" { eprintln!("json.sort_keys is unsupported; pipe through jq -S instead"); }
} Try / catch
let out = Command::new("http").args([&"--format-options=json.sort_keys=true", ...]).output()?;
if !out.status.success() && String::from_utf8_lossy(&out.stderr).contains("Unsupported option") {
eprintln!("json.sort_keys unsupported; use: http ... | jq -S .");
} Prevention
- Don't pass json.sort_keys; sort JSON with jq -S or a post-processor
- Check --help for supported format-options keys in your version
- Pin tool version in scripts and validate option names against it
When it happens
Trigger: Passing --format-options=json.sort_keys=true (or any value) on the command line; the key is matched by an explicit arm that errors.
Common situations: Users assuming JSON output supports a sort_keys toggle similar to Python's json.dumps; copying format options from other HTTPie-like tools.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Unknown option
- expected \n\n
- JSON values are not supported in Form fields
- JSON values are not supported in multipart fields
- Can't use file fields in JSON mode (perhaps you meant…
AI-assisted analysis of ducaale/xh@2404aceecc (2026-09-13).
Data as JSON: /api/errors/a2a4c8de81939640.
Report an issue: GitHub.
Appendix: source
Thrown at src/cli.rs:1043
match key {
"json.indent" => {
format_options.json_indent = Some(value.parse().with_context(value_error)?);
}
"json.format" => {
format_options.json_format = Some(value.parse().with_context(value_error)?);
}
"headers.sort" => {
format_options.headers_sort = Some(value.parse().with_context(value_error)?);
}
"xml.indent" => {
format_options.xml_indent = Some(value.parse().with_context(value_error)?);
}
"xml.format" => {
format_options.xml_format = Some(value.parse().with_context(value_error)?);
}
"json.sort_keys" => {
return Err(anyhow!("Unsupported option '{key}'"));
}
_ => {
return Err(anyhow!("Unknown option '{key}'"));
}
}
}
Ok(format_options)
}
}
#[derive(Default, ValueEnum, Debug, PartialEq, Eq, Clone, Copy)]
pub enum Theme {
#[default]
Auto,
Solarized,
Monokai,
Fruity,
}View on GitHub (pinned to 2404aceecc)