{"record":{"id":"a1e02eb75f6fa357","repo":"wasmerio/wasmer","slug":"invalid-map-command-flag-alias-cannot-be-empty","errorCode":null,"errorMessage":"Invalid --map-command flag - alias cannot be empty: '{item}'","messagePattern":"Invalid --map-command flag - alias cannot be empty: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/cli/src/commands/run/wasi.rs","lineNumber":555,"sourceCode":"\n        Ok((have_current_dir, mapped_dirs))\n    }\n\n    pub fn build_mapped_commands(&self) -> Result<Vec<MappedCommand>, anyhow::Error> {\n        self.map_commands\n            .iter()\n            .map(|item| {\n                let (a, b) = item.split_once('=').with_context(|| {\n                    format!(\n                        \"Invalid --map-command flag: expected <ALIAS>=<HOST_PATH>, got '{item}'\"\n                    )\n                })?;\n\n                let a = a.trim();\n                let b = b.trim();\n\n                if a.is_empty() {\n                    bail!(\"Invalid --map-command flag - alias cannot be empty: '{item}'\");\n                }\n                // TODO(theduke): check if host command exists, and canonicalize PathBuf.\n                if b.is_empty() {\n                    bail!(\"Invalid --map-command flag - host path cannot be empty: '{item}'\");\n                }\n\n                Ok(MappedCommand {\n                    alias: a.to_string(),\n                    target: b.to_string(),\n                })\n            })\n            .collect::<Result<Vec<_>, anyhow::Error>>()\n    }\n\n    pub fn capabilities(&self) -> Capabilities {\n        let mut caps = Capabilities::default();\n\n        if self.http_client {","sourceCodeStart":537,"sourceCodeEnd":573,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/cli/src/commands/run/wasi.rs#L537-L573","documentation":"build_mapped_commands parses each --map-command item as ALIAS=HOST_PATH, trimming both sides. If the alias side (before '=') is empty, the mapping is meaningless so it is rejected with this message, which echoes the raw offending item. The TODO notes the host path is not yet canonicalized or checked for existence.","triggerScenarios":"Passing a --map-command item like `=/bin/ls`, ` =/bin/ls`, or a malformed `=path` where the text before '=' trims to empty during prepare().","commonSituations":"Leading '=' typo in the flag; programmatically built flag strings where the alias variable was empty; splitting a comma/whitespace-separated list that produced an empty alias segment.","solutions":["Provide a non-empty alias before the '=' sign, e.g. --map-command ls=/bin/ls","Inspect the offending item echoed in the message and fix the flag ordering/separator","Filter out empty entries when building --map-command flags in scripts"],"exampleFix":"// before\nwasmer run app.wasm --map-command =/bin/ls\n// after\nwasmer run app.wasm --map-command ls=/bin/ls","handlingStrategy":"validation","validationCode":"fn validate_map_command(item: &str) -> Result<(), String> {\n    let (a, b) = item.split_once('=')\n        .ok_or_else(|| format!(\"--map-command must be ALIAS=HOST_PATH, got {item:?}\"))?;\n    if a.trim().is_empty() { Err(format!(\"empty alias in {item:?}\")) } else { Ok(()) }\n}","typeGuard":"fn has_nonempty_alias(item: &str) -> bool {\n    item.split_once('=').map(|(a, _)| !a.trim().is_empty()).unwrap_or(false)\n}","tryCatchPattern":"match wasmer_run_with_map_commands(&items) {\n    Err(e) if e.to_string().contains(\"alias cannot be empty\") => {\n        let fixed: Vec<_> = items.iter().filter(|i| has_nonempty_alias(i)).collect();\n        wasmer_run_with_map_commands(&fixed)\n    }\n    other => other,\n}","preventionTips":["Always write --map-command as ALIAS=HOST_PATH with a real alias name","Filter empty segments when building flag lists programmatically","Validate every mapping with split_once('=') before spawning wasmer"],"tags":["cli","wasi","argument-validation","map-command"],"backgroundTag":"invalid-flag-argument","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}