{"record":{"id":"c491442f699f8e29","repo":"windmill-labs/windmill","slug":"cannot-parse-default-value-for-argument","errorCode":null,"errorMessage":"Cannot parse default value for argument","messagePattern":"Cannot parse default value for argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-nu/src/lib.rs","lineNumber":81,"sourceCode":"            compensate_lookahead -= 1;\n            continue;\n        }\n\n        let type_start = batch.find(\":\");\n        let default_start = batch.find(\"=\");\n\n        let (name, typ, default) = match (type_start, default_start) {\n            (None, None) => (batch.trim(), None, None),\n            (None, Some(d)) => (\n                batch\n                    .get(0..d)\n                    .ok_or(anyhow!(\"Cannot parse argument ident\"))?\n                    .trim(),\n                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)) => {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-nu/src/lib.rs#L63-L99","documentation":"parse_nu_signature in windmill-parser-nu locates the `=` that starts an argument's default value and slices the remainder of the batch with `batch.get(d..)` before handing it to parse_default. When that byte range cannot be taken (None from `str::get`), the parser raises this error instead of panicking — it means the default-value portion of the argument is not sliceable at the found offset.","triggerScenarios":"parse_nu_signature is given a Nushell script whose main-args batch contains `=` at byte index `d`, but `get(d..)` fails — e.g. the `=` byte sits at the very end in a corrupted token or a multibyte character sequence makes the range boundary invalid, so the default value text cannot be extracted.","commonSituations":"A script pasted into Windmill with broken/mixed encodings so the bytes after `=` are invalid in context; hand-edited hub scripts where an argument default was deleted leaving a dangling `=` at the end of a line.","solutions":["Inspect the `def main [ ... ]` argument list in the script; ensure each argument with a default has well-formed content after `=`, e.g. `x = \"foo\"`.","Remove dangling `=` markers with no value after them, or give the argument a JSON-serializable default (`string`, number, bool, list, or flat record).","Re-save the file as clean UTF-8; multibyte corruption around the default marker can make the slice impossible.","If the default is a list/record spanning commas, keep it on-parseable lines — nesting (`[[1],[2]]` or records inside records) is not supported and produces related parse bail-outs."],"exampleFix":"// before\ndef main [x = ] { $x }\n\n// after\ndef main [x = 42] { $x }","handlingStrategy":"validation","validationCode":"// Ensure every '=' in def main args is followed by a parseable default value\nfn validate_nu_defaults(code: &str) -> Result<(), 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(d) = b.find('=') {\n            let default = b.get(d..).unwrap_or(\"\").trim_start_matches('=').trim();\n            if default.is_empty() {\n                return Err(format!(\"dangling '=' in argument {b:?}\"));\n            }\n        }\n    }\n    Ok(())\n}","typeGuard":"fn has_sliceable_default(batch: &str, d: usize) -> bool {\n    batch.is_char_boundary(d)\n        && batch.get(d..).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 default value\") => {\n        eprintln!(\"malformed default value in def main args: {e}\");\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Write defaults as JSON-serializable literals: strings, numbers, bools, flat lists/records","Never leave a dangling '=' without a value in the argument list","Avoid nested lists/records in defaults (unsupported by this parser)","Re-save damaged files as clean UTF-8 before deploying"],"tags":["nushell","parser","default-value","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"}