{"record":{"id":"918fc35ac941485e","repo":"windmill-labs/windmill","slug":"cannot-parse-type-of-argument","errorCode":null,"errorMessage":"Cannot parse type of argument","messagePattern":"Cannot parse type of argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-nu/src/lib.rs","lineNumber":95,"sourceCode":"                None,\n                Some(parse_default(\n                    &batch\n                        .get(d..)\n                        .ok_or(anyhow!(\"Cannot parse default value for argument\"))?,\n                    &batches,\n                    i,\n                    &mut compensate_lookahead,\n                )?),\n            ),\n            (Some(t), None) => (\n                batch\n                    .get(0..t)\n                    .ok_or(anyhow!(\"Cannot parse argument ident\"))?\n                    .trim(),\n                Some(parse_type(\n                    &batch\n                        .get(t..)\n                        .ok_or(anyhow!(\"Cannot parse type of argument\"))?,\n                )?),\n                None,\n            ),\n            (Some(t), Some(d)) => {\n                if t < d {\n                    (\n                        batch\n                            .get(0..t)\n                            .ok_or(anyhow!(\"Cannot parse argument ident\"))?\n                            .trim(),\n                        Some(parse_type(\n                            &batch\n                                .get(t..d)\n                                .ok_or(anyhow!(\"Cannot parse type of argument\"))?,\n                        )?),\n                        Some(parse_default(\n                            &batch\n                                .get(d..)","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-nu/src/lib.rs#L77-L113","documentation":"parse_nu_signature slices the type annotation of a Nushell main-args argument with `batch.get(t..)`, where `t` is the byte offset of `:`, and passes the result to parse_type. When the range cannot be sliced (str::get returns None) this anyhow error is raised; it guards the extraction of the `: type` portion of the argument.","triggerScenarios":"parse_nu_signature encounters a batch with a `:` type marker at offset `t` such that `get(t..)` is not a valid byte range — e.g. the `:` byte lies at the end of a corrupted token or inside a broken multibyte sequence, so the type text cannot be recovered.","commonSituations":"Scripts whose argument list was truncated mid-token by a bad save/merge (e.g. `x:` at end of file with lost bytes), or generated signatures with encoding corruption around the type marker.","solutions":["Ensure every typed argument has complete text after `:` — e.g. `x: string`, not a truncated `x:`.","Compare the script against a working version (git history or hub original) and restore the argument list.","Re-encode the file as UTF-8 without BOM and remove stray bytes around the argument list.","Check the type keyword against the supported list; unsupported types fail later in parse_type with a different message, but malformed bytes around `:` fail here."],"exampleFix":"// before (truncated type token)\ndef main [x:] { $x }\n\n// after\ndef main [x: int] { $x }","handlingStrategy":"validation","validationCode":"// Ensure each ':' type marker is followed by a supported type keyword\nfn validate_nu_types(code: &str) -> Result<(), String> {\n    const SUPPORTED: &[&str] = &[\"string\", \"int\", \"float\", \"number\", \"record\", \"table\",\n        \"nothing\", \"datetime\", \"any\", \"bool\", \"list\", \"list<any>\", \"list<nothing>\",\n        \"list<number>\", \"list<bool>\", \"list<string>\"];\n    let args = code\n        .split(\"def main\").nth(1)\n        .and_then(|r| r.split('[').nth(1))\n        .and_then(|r| r.split(']').next())\n        .ok_or(\"no def main args\")?;\n    for batch in args.split(',') {\n        let b = batch.trim();\n        if let Some(t) = b.find(':') {\n            let ty = b.get(t..).unwrap_or(\"\").trim_start_matches(':').trim();\n            if ty.is_empty() {\n                return Err(format!(\"missing type after ':' in {b:?}\"));\n            }\n            if !SUPPORTED.contains(&ty) {\n                return Err(format!(\"unsupported type '{ty}' in {b:?}\"));\n            }\n        }\n    }\n    Ok(())\n}","typeGuard":"fn has_sliceable_type(batch: &str, t: usize) -> bool {\n    batch.is_char_boundary(t)\n        && batch.get(t..).map_or(false, |s| !s.trim_start_matches(':').trim().is_empty())\n}","tryCatchPattern":"match parse_nu_signature(&nu_code) {\n    Ok(sig) => deploy(sig),\n    Err(e) if e.to_string().contains(\"Cannot parse type of argument\") => {\n        eprintln!(\"malformed type annotation in def main args: {e}\");\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Always write a complete type after ':' — never truncate like `x:`","Stick to the supported type list (no record<...> or table<...>, no list<float/int>)","Keep the file UTF-8-clean around the argument list","Restore from git/hub if the signature looks corrupted"],"tags":["nushell","parser","type-annotation","signature","windmill"],"backgroundTag":"nu-signature-parse-failed","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}