{"record":{"id":"47dd5542c0c1ff6d","repo":"windmill-labs/windmill","slug":"internal-error-failed-to-get-child-by-field-name","errorCode":null,"errorMessage":"Internal error: Failed to get child by field name 'type'","messagePattern":"Internal error: Failed to get child by field name 'type'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-java/src/lib.rs","lineNumber":172,"sourceCode":"    };\n    Ok(res)\n}\n\nfn parse_java_typ<'a>(\n    param_node: Node<'a>,\n    code: &str,\n) -> anyhow::Result<(Option<String>, Typ, String, Option<Value>)> {\n    let name = param_node\n        .child_by_field_name(\"name\")\n        .and_then(|n| n.utf8_text(code.as_bytes()).ok())\n        .unwrap_or(\"\");\n    let otyp_node = param_node.child_by_field_name(\"type\");\n    let otyp = otyp_node\n        .and_then(|n| n.utf8_text(code.as_bytes()).ok())\n        .map(|s| s.to_string());\n\n    let (typ, default) = find_typ(\n        otyp_node.ok_or(anyhow!(\n            \"Internal error: Failed to get child by field name 'type'\"\n        ))?,\n        code,\n    )?;\n\n    Ok((otyp, typ, name.to_string(), default))\n}\n\n// Function to find the Main method's signature\nfn find_main_signature<'a>(root_node: Node<'a>, code: &str) -> Option<(Node<'a>, Option<String>)> {\n    let mut cursor = root_node.walk();\n    for x in root_node.children(&mut cursor) {\n        if x.kind() == \"class_declaration\" {\n            let class_name = x\n                .child_by_field_name(\"name\")\n                .and_then(|n| n.utf8_text(code.as_bytes()).ok().map(|s| s.to_string()));\n            for c in x.children(&mut x.walk()) {\n                if c.kind() == \"class_body\" {","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-java/src/lib.rs#L154-L190","documentation":"Raised by parse_java_typ when a `formal_parameter` node produced by the tree-sitter Java grammar has no child under the field name `type` — i.e. the parameter node exists but carries no type. The function labels it \"Internal error\" because a well-formed formal_parameter always has a type field; hitting it means the AST node is malformed, almost always the product of tree-sitter error recovery on syntactically invalid Java.","triggerScenarios":"parse_java_sig_meta walks the `parameters` field of a `main` method and calls parse_java_typ on each formal_parameter node; the error fires when a parameter declaration in the source is incomplete or the grammar recovered an ERROR node — e.g. `static void main(String, int x)` (unnamed/untyped parameter), `main(a b)`, or a parameter cut off by a truncation/syntax error elsewhere in the method signature.","commonSituations":"Hand-edited Java scripts saved in the Windmill editor with a malformed `main` signature (missing type, stray comma, unbalanced parentheses); pasting code that was truncated mid-signature; generated code from templates where a placeholder type was never filled in.","solutions":["Correct the `main` method signature so every parameter is `Type name`, e.g. `public static void main(String[] args, int count)` — each formal parameter needs both type and name.","Remove or fix stray tokens around the parameter list (double commas, unbalanced parentheses, `final` misuse) so the grammar doesn't fall into error recovery.","Validate the Java file compiles/parses independently (IDE or `javac`) before saving it as a Windmill script; fix earlier syntax errors that corrupt downstream AST nodes.","If this occurs on syntactically valid Java, upgrade tree-sitter-java — grammar drift can change field names — and file an issue with the failing snippet."],"exampleFix":"// before (parameter without a type -> formal_parameter node has no 'type' field)\nclass Main { public static void main(String[] args, count) {} }\n\n// after (fully typed parameters)\nclass Main { public static void main(String[] args, int count) {} }","handlingStrategy":"validation","validationCode":"// Verify each main() parameter is fully typed before handing code to the parser:\nfn params_all_typed(code: &str) -> bool {\n    // reject patterns like \"(\" followed by an ident not preceded by a type,\n    // double commas, or an empty parameter slot\n    !code.contains(\",,\") && !code.contains(\"(,\") && !code.contains(\",)\")\n        // a parameter starting with a lowercase name before any known primitive/wrapper\n        // should at minimum be reviewed\n}","typeGuard":null,"tryCatchPattern":"match parse_java_signature(code) {\n    Ok(sig) => sig,\n    Err(e) if e.to_string().contains(\"child by field name 'type'\") => {\n        // malformed parameter in main(): report which signature to fix\n        bail!(\"Every parameter of main() must be declared as 'Type name'\")\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Declare every parameter as `Type name` — never an unnamed or typeless parameter in main().","Check parentheses and commas in the parameter list are balanced before saving.","Compile-check the script locally (javac/IDE) when possible before deploying to Windmill.","Treat this as a user-signature error, not a bug: map the message to editor feedback."],"tags":["rust","java","parser","ast"],"backgroundTag":"unparseable-function-signature","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"}