{"record":{"id":"6872a0cd99393005","repo":"ducaale/xh","slug":"message-signature-components-require-both-unstable-m-sig-id","errorCode":null,"errorMessage":"Message signature components require both --unstable-m-sig-id and --unstable-m-sig-key.","messagePattern":"Message signature components require both --unstable-m-sig-id and --unstable-m-sig-key\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":605,"sourceCode":"\n        for header in &headers_to_unset {\n            request.headers_mut().remove(header);\n        }\n\n        #[cfg(not(feature = \"http-message-signatures\"))]\n        if args.m_sig.m_sig_id.is_some()\n            || args.m_sig.m_sig_key.is_some()\n            || args.m_sig.m_sig_alg.is_some()\n            || args.m_sig.has_components()\n        {\n            return Err(anyhow!(\n                \"This binary was built without message signature support. Enable the `http-message-signatures` feature.\"\n            ));\n        }\n\n        #[cfg(feature = \"http-message-signatures\")]\n        if args.m_sig.has_components() && !args.m_sig.has_key_pair() {\n            return Err(anyhow!(\n                \"Message signature components require both --unstable-m-sig-id and --unstable-m-sig-key.\"\n            ));\n        }\n\n        #[cfg(feature = \"http-message-signatures\")]\n        if let Some((key_id, key_material)) = args.m_sig.key_pair() {\n            let m_sig_components = args.m_sig.flattened_components();\n            let m_sig_algorithm = args.m_sig.algorithm().map(Into::into);\n            message_signature::sign_request(\n                &mut request,\n                key_id,\n                key_material,\n                (!m_sig_components.is_empty()).then_some(m_sig_components.as_slice()),\n                m_sig_algorithm,\n            )?;\n        }\n\n        request","sourceCodeStart":587,"sourceCodeEnd":623,"githubUrl":"https://github.com/ducaale/xh/blob/2404aceecc08b0b2d100fedc96f57745cd5904dc/src/main.rs#L587-L623","documentation":"When message signature support is enabled, signing requires an identity: both a key ID (`--unstable-m-sig-id`) and key material (`--unstable-m-sig-key`). Supplying signature components without a complete key pair leaves the signer unable to construct a `SignatureSpec`, so `run` rejects the combination up front.","triggerScenarios":"Passing signature component flags (e.g. `--unstable-m-sig-components`) with only one of `--unstable-m-sig-id` / `--unstable-m-sig-key`, or with neither, while the `http-message-signatures` feature is enabled (`has_components() && !has_key_pair()`).","commonSituations":"Partially copying example commands from documentation; env-var-driven config where one of the two values is unset; switching between shared-secret and key-based setups and dropping a flag.","solutions":["Provide both flags together: `--unstable-m-sig-id <id> --unstable-m-sig-key <key>`.","Remove the signature component flags entirely if you did not intend to sign the request.","Check that the key/id values are actually being passed (not empty env vars) in your script."],"exampleFix":"// before\nxh --unstable-m-sig-components=\"@authority\" POST https://api.example.com\n// after\nxh --unstable-m-sig-id=my-key-id --unstable-m-sig-key=$SECRET --unstable-m-sig-components=\"@authority\" POST https://api.example.com","handlingStrategy":"validation","validationCode":"# shell guard before invoking xh:\nif [[ -n \"$M_SIG_COMPONENTS\" && ( -z \"$M_SIG_ID\" || -z \"$M_SIG_KEY\" ) ]]; then\n  echo 'm-sig components require both id and key'; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --unstable-m-sig-id and --unstable-m-sig-key as a pair.","Fail fast in scripts when either env var is empty.","Keep signing flags in one shared script function to avoid drift."],"tags":["cli","arguments","http","security"],"backgroundTag":"missing-required-argument","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"}