windmill-labs/windmill · error

Impossible to parse arg digit

Error message

Impossible to parse arg digit

What it means

parse_pg_file reads PostgreSQL argument declarations from `-- $1 argName (type)` comments and extracts the positional index via regex capture group 1. If the captured text cannot parse as i32 the signature is unparseable, so it fails with this message rather than silently mis-indexing arguments.

Source

Thrown at backend/parsers/windmill-parser-sql/src/lib.rs:586

                positions.push((arg_idx, start..end));
            }
        },
    );
    positions
}

fn parse_pg_file(code: &str) -> anyhow::Result<Option<(Vec<Arg>, bool)>> {
    let mut args = vec![];

    // Track which args have explicit types in declaration comments
    let mut explicitly_typed_args: HashSet<i32> = HashSet::new();

    // First pass: collect args from declaration comments (-- $1 argName (type))
    for cap in RE_ARG_PGSQL.captures_iter(code) {
        let idx = cap
            .get(1)
            .and_then(|x| x.as_str().parse::<i32>().ok())
            .ok_or_else(|| anyhow!("Impossible to parse arg digit"))?;

        let name = cap.get(2).map(|x| x.as_str().to_string()).unwrap();
        let explicit_type = cap.get(3).map(|x| x.as_str().to_string().to_lowercase());
        let default = cap.get(4).map(|x| x.as_str().to_string());
        let has_default = default.is_some();

        if let Some(typ) = explicit_type {
            // If explicitly typed, use that type and don't infer from usage
            explicitly_typed_args.insert(idx);
            let parsed_typ = parse_pg_typ(typ.as_str());
            let parsed_default = default.and_then(|x| parsed_default(&parsed_typ, x));

            args.push(Arg {
                name,
                typ: parsed_typ,
                default: parsed_default,
                otyp: Some(typ),
                has_default,

View on GitHub (pinned to e474e8803c)

Solutions

  1. Rewrite the argument comment to the exact form `-- $1 argName (type)` with a numeric position
  2. Check for typos like `$O` (letter O) or `$l` instead of digits
  3. Ensure every argument comment starts with `$<number>`

Example fix

// before
-- $foo myarg (int)
// after
-- $1 myarg (int)
Defensive patterns

Strategy: validation

Validate before calling

/^--\s+\$(\d+)\s+(\w+)(?:\s+\(([^)]+)\))?/m.test(pgCode) // ensure every arg comment has a numeric $N
const bad = pgCode.match(/^--\s+\$[^\d\s]/gm); if (bad) throw new Error('Non-numeric arg position: ' + bad);

Try / catch

try {
  parsePgsqlSig(code);
} catch (e) {
  if (String(e).includes('Impossible to parse arg digit')) {
    // point user to the malformed `-- $N` comment
  } else throw e;
}

Prevention

When it happens

Trigger: parse_pg_file (via parse_pgsql_sig_with_typed_schema) encountering an argument comment whose first capture group is missing or is not an integer — e.g. a comment like `-- $x name` or `-- name type` that coincidentally matches the regex but has no digit.

Common situations: Hand-written Postgres script comments that deviate from the `-- $N name (type)` convention, missing the `$` position, or using a non-numeric placeholder.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/5ae8ab92199fc8c1. Report an issue: GitHub.