windmill-labs/windmill · error
Internal error: Failed to get child by field name 'type'
Error message
Internal error: Failed to get child by field name 'type'
What it means
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.
Source
Thrown at backend/parsers/windmill-parser-java/src/lib.rs:172
};
Ok(res)
}
fn parse_java_typ<'a>(
param_node: Node<'a>,
code: &str,
) -> anyhow::Result<(Option<String>, Typ, String, Option<Value>)> {
let name = param_node
.child_by_field_name("name")
.and_then(|n| n.utf8_text(code.as_bytes()).ok())
.unwrap_or("");
let otyp_node = param_node.child_by_field_name("type");
let otyp = otyp_node
.and_then(|n| n.utf8_text(code.as_bytes()).ok())
.map(|s| s.to_string());
let (typ, default) = find_typ(
otyp_node.ok_or(anyhow!(
"Internal error: Failed to get child by field name 'type'"
))?,
code,
)?;
Ok((otyp, typ, name.to_string(), default))
}
// Function to find the Main method's signature
fn find_main_signature<'a>(root_node: Node<'a>, code: &str) -> Option<(Node<'a>, Option<String>)> {
let mut cursor = root_node.walk();
for x in root_node.children(&mut cursor) {
if x.kind() == "class_declaration" {
let class_name = x
.child_by_field_name("name")
.and_then(|n| n.utf8_text(code.as_bytes()).ok().map(|s| s.to_string()));
for c in x.children(&mut x.walk()) {
if c.kind() == "class_body" {View on GitHub (pinned to e474e8803c)
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.
Example fix
// before (parameter without a type -> formal_parameter node has no 'type' field)
class Main { public static void main(String[] args, count) {} }
// after (fully typed parameters)
class Main { public static void main(String[] args, int count) {} } Defensive patterns
Strategy: validation
Validate before calling
// Verify each main() parameter is fully typed before handing code to the parser:
fn params_all_typed(code: &str) -> bool {
// reject patterns like "(" followed by an ident not preceded by a type,
// double commas, or an empty parameter slot
!code.contains(",,") && !code.contains("(,") && !code.contains(",)")
// a parameter starting with a lowercase name before any known primitive/wrapper
// should at minimum be reviewed
} Try / catch
match parse_java_signature(code) {
Ok(sig) => sig,
Err(e) if e.to_string().contains("child by field name 'type'") => {
// malformed parameter in main(): report which signature to fix
bail!("Every parameter of main() must be declared as 'Type name'")
}
Err(e) => return Err(e),
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to find inner type of array type
- Unknown type `{s}`
- Failed to parse code
- Aborted from C
- vsnprintf is not supported
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/47dd5542c0c1ff6d.
Report an issue: GitHub.