{"record":{"id":"5ae8ab92199fc8c1","repo":"windmill-labs/windmill","slug":"impossible-to-parse-arg-digit-5ae8ab","errorCode":null,"errorMessage":"Impossible to parse arg digit","messagePattern":"Impossible to parse arg digit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-sql/src/lib.rs","lineNumber":586,"sourceCode":"                positions.push((arg_idx, start..end));\n            }\n        },\n    );\n    positions\n}\n\nfn parse_pg_file(code: &str) -> anyhow::Result<Option<(Vec<Arg>, bool)>> {\n    let mut args = vec![];\n\n    // Track which args have explicit types in declaration comments\n    let mut explicitly_typed_args: HashSet<i32> = HashSet::new();\n\n    // First pass: collect args from declaration comments (-- $1 argName (type))\n    for cap in RE_ARG_PGSQL.captures_iter(code) {\n        let idx = cap\n            .get(1)\n            .and_then(|x| x.as_str().parse::<i32>().ok())\n            .ok_or_else(|| anyhow!(\"Impossible to parse arg digit\"))?;\n\n        let name = cap.get(2).map(|x| x.as_str().to_string()).unwrap();\n        let explicit_type = cap.get(3).map(|x| x.as_str().to_string().to_lowercase());\n        let default = cap.get(4).map(|x| x.as_str().to_string());\n        let has_default = default.is_some();\n\n        if let Some(typ) = explicit_type {\n            // If explicitly typed, use that type and don't infer from usage\n            explicitly_typed_args.insert(idx);\n            let parsed_typ = parse_pg_typ(typ.as_str());\n            let parsed_default = default.and_then(|x| parsed_default(&parsed_typ, x));\n\n            args.push(Arg {\n                name,\n                typ: parsed_typ,\n                default: parsed_default,\n                otyp: Some(typ),\n                has_default,","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-sql/src/lib.rs#L568-L604","documentation":"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.","triggerScenarios":"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.","commonSituations":"Hand-written Postgres script comments that deviate from the `-- $N name (type)` convention, missing the `$` position, or using a non-numeric placeholder.","solutions":["Rewrite the argument comment to the exact form `-- $1 argName (type)` with a numeric position","Check for typos like `$O` (letter O) or `$l` instead of digits","Ensure every argument comment starts with `$<number>`"],"exampleFix":"// before\n-- $foo myarg (int)\n// after\n-- $1 myarg (int)","handlingStrategy":"validation","validationCode":"/^--\\s+\\$(\\d+)\\s+(\\w+)(?:\\s+\\(([^)]+)\\))?/m.test(pgCode) // ensure every arg comment has a numeric $N\nconst bad = pgCode.match(/^--\\s+\\$[^\\d\\s]/gm); if (bad) throw new Error('Non-numeric arg position: ' + bad);","typeGuard":null,"tryCatchPattern":"try {\n  parsePgsqlSig(code);\n} catch (e) {\n  if (String(e).includes('Impossible to parse arg digit')) {\n    // point user to the malformed `-- $N` comment\n  } else throw e;\n}","preventionTips":["Write arg comments exactly as `-- $1 name (type)`","Never hand-edit the `$N` position to a non-digit","Keep one comment per argument, numbered sequentially"],"tags":["postgresql","signature-parsing","regex","sql-parser"],"backgroundTag":"invalid-argument-declaration","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"}