windmill-labs/windmill · error
Cannot parse default value of argument
Error message
Cannot parse default value of argument
What it means
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.
Source
Thrown at backend/parsers/windmill-parser-nu/src/lib.rs:114
)?),
None,
),
(Some(t), Some(d)) => {
if t < d {
(
batch
.get(0..t)
.ok_or(anyhow!("Cannot parse argument ident"))?
.trim(),
Some(parse_type(
&batch
.get(t..d)
.ok_or(anyhow!("Cannot parse type of argument"))?,
)?),
Some(parse_default(
&batch
.get(d..)
.ok_or(anyhow!("Cannot parse default value of argument"))?,
&batches,
i,
&mut compensate_lookahead,
)?),
)
} else {
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.")
}
}
};
// Check if it is optional
let optional = {
let Some(element) = name.chars().last() else {
bail!("Internal error, cannot check if argument is optional")
};
element == '?'
};View on GitHub (pinned to e474e8803c)
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.
Example fix
// before x: int = = 3 // after x: int = 3
Defensive patterns
Strategy: validation
Validate before calling
// Ensure every defaulted param has exactly one well-formed '= default'
function validateNuDefaults(code) {
const m = /def\s+main\s*\[([^\]]*)\]/s.exec(code);
if (!m) return;
for (const p of m[1].split(',').map(s => s.trim()).filter(Boolean)) {
const eq = (p.match(/=/g) || []).length;
if (eq > 1) throw new Error(`param has multiple '=': ${p}`);
if (eq === 1 && !/^[\w-]+\s*:\s*\S+\s*=\s*\S/.test(p))
throw new Error(`malformed default: ${p}`);
}
} Try / catch
try {
const sig = await parseNuSignature(code);
} catch (e) {
if (String(e.message).includes('Cannot parse default value')) {
sig = { params: [], error: 'invalid Nu default value' };
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Parsing error `:` should be before `=` it likely means you a
- Nesting is not supported
- Parsing error
- Cannot parse default value for argument
- ${inferedSchema.error}
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/2df1a9364d4471b1.
Report an issue: GitHub.