{"record":{"id":"2df1a9364d4471b1","repo":"windmill-labs/windmill","slug":"cannot-parse-default-value-of-argument","errorCode":null,"errorMessage":"Cannot parse default value of argument","messagePattern":"Cannot parse default value of argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-nu/src/lib.rs","lineNumber":114,"sourceCode":"                )?),\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..)\n                                .ok_or(anyhow!(\"Cannot parse default value of argument\"))?,\n                            &batches,\n                            i,\n                            &mut compensate_lookahead,\n                        )?),\n                    )\n                } else {\n                    bail!(\"Parsing error `:` should be before `=`\\nit likely means you are trying to set default value to record or table which is not supported at the moment.\")\n                }\n            }\n        };\n\n        // Check if it is optional\n        let optional = {\n            let Some(element) = name.chars().last() else {\n                bail!(\"Internal error, cannot check if argument is optional\")\n            };\n            element == '?'\n        };","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-nu/src/lib.rs#L96-L132","documentation":"windmill-parser-nu throws this when slicing the default-value segment of a Nu parameter (batch.get(d..)) fails during parse_nu_signature. The offsets that mark where the default value should begin don't fit the actual parameter text, so the parser cannot extract a default it believes exists and aborts.","triggerScenarios":"Calling parse_nu_signature on Nu code where a parameter appears to have a default value (the '=' offset d was detected) but the text from d to end of batch cannot be extracted — typically malformed spacing around '=' or a truncated/default region inside a multiline parameter list.","commonSituations":"Hand-edited Nu signatures with missing or doubled '=' (e.g. 'x: int = = 3'), defaults written across lines, or copy-pasted signatures with unusual whitespace that the offset splitter misreads.","solutions":["Check each parameter with a default in def main [ ... ] for a well-formed single '= default' expression on one line.","Remove duplicate '=' signs or stray tokens around the default value.","Keep the whole parameter (name: type = default) on a single line inside the bracket list.","If the default is complex, simplify it or move the computation into the function body so the signature stays plain.","Report valid-but-rejected Nu syntax to windmill-parser-nu maintainers with the exact snippet."],"exampleFix":"// before\nx: int = = 3\n\n// after\nx: int = 3","handlingStrategy":"validation","validationCode":"// Ensure every defaulted param has exactly one well-formed '= default'\nfunction validateNuDefaults(code) {\n  const m = /def\\s+main\\s*\\[([^\\]]*)\\]/s.exec(code);\n  if (!m) return;\n  for (const p of m[1].split(',').map(s => s.trim()).filter(Boolean)) {\n    const eq = (p.match(/=/g) || []).length;\n    if (eq > 1) throw new Error(`param has multiple '=': ${p}`);\n    if (eq === 1 && !/^[\\w-]+\\s*:\\s*\\S+\\s*=\\s*\\S/.test(p))\n      throw new Error(`malformed default: ${p}`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const sig = await parseNuSignature(code);\n} catch (e) {\n  if (String(e.message).includes('Cannot parse default value')) {\n    sig = { params: [], error: 'invalid Nu default value' };\n  } else throw e;\n}","preventionTips":["Write defaults as simple one-line expressions in the signature","Move complex computations out of the parameter default into the body","Never hand-edit signatures with doubled '=' or stray tokens","Round-trip the script through the Nu CLI to validate syntax"],"tags":["nu","parser","default-value"],"backgroundTag":"script-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"}