windmill-labs/windmill · error

Failed to find inner type of array type

Error message

Failed to find inner type of array type

What it means

Raised by find_typ when it encounters an `array_type` AST node whose element type is missing: `named_child(0)` returned None, meaning the array node has no named child to recurse into. tree-sitter's Java grammar normally always attaches the element type as the named child of an array_type, so this is an internal invariant violation — it fires only on a malformed/ERROR-recovered node where the element type could not be parsed.

Source

Thrown at backend/parsers/windmill-parser-java/src/lib.rs:145

        "floating_point_type" => {
            match typ_node.utf8_text(code.as_bytes()) {
                Ok("float") => (Typ::Float, None),
                Ok("double") => (Typ::Float, None),
                Ok(s) => bail!("Unknown type `{s}`"),
                Err(e) => bail!("Error getting type name: {}", e),
            }
        }
        "boolean_type" => {
            match typ_node.utf8_text(code.as_bytes()) {
                Ok("boolean") => (Typ::Bool, None),
                Ok(s) => bail!("Unknown type `{s}`"),
                Err(e) => bail!("Error getting type name: {}", e),
            }
        }
        "array_type" => {
            let new_typ_node = typ_node
                .named_child(0)
                .ok_or(anyhow!("Failed to find inner type of array type"))?;
            (Typ::List(Box::new(find_typ(new_typ_node, code)?.0)), null)
        }
        wc => bail!(
            "Unexpected Java type node kind: {} for '{}'. This type is not handled by Windmill, please open an issue if this seems to be an error",
            wc,
            typ_node.utf8_text(code.as_bytes())?
        ),

    };
    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")

View on GitHub (pinned to e474e8803c)

Solutions

  1. Fix the Java source: ensure every array parameter has a complete element type, e.g. `public static void main(String[] args)`, with balanced brackets and no truncation.
  2. Fix syntax errors elsewhere in the file first — a preceding ERROR node can leave the array_type node malformed; validate the file with `javac -proc:only` or an IDE before deploying.
  3. If your code legitimately triggers this on well-formed Java, upgrade tree-sitter-java (older grammar versions had different node shapes) and re-test.
  4. Consider treating it as a user-input error upstream: catch it and surface 'cannot parse parameter type' instead of an internal error message.

Example fix

// before (truncated/broken Java given to the parser)
class Main { public static void main(int[]) {} }

// after (complete element type)
class Main { public static void main(int[] a) {} }
Defensive patterns

Strategy: validation

Validate before calling

// Cheap pre-check in Java source before submitting to the parser:
// every array parameter must have an element type
fn looks_like_broken_array_param(code: &str) -> bool {
    code.contains("[])") || code.contains("[] ") && code.contains("main(")
        // e.g. "main(int[])" — bracket pair with no identifier following
}

Try / catch

match parse_java_signature(code) {
    Ok(sig) => sig,
    Err(e) if e.to_string().contains("inner type of array type") => {
        // surface as user-input error: "a main() parameter has an incomplete array type"
        bail!("Fix the array parameter type in your main() signature")
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling parse_java_signature/parse_java_sig_meta on Java code where a `main` method parameter is an array type with an unparseable or missing element type — e.g. source truncated mid-declaration like `static void main(int[])` or `main(String[] )` inside code containing syntax errors so the grammar produces a degenerate array_type node.

Common situations: Users pasting incomplete Java scripts into the Windmill editor (the signature parser runs on save to build the UI argument form); programmatic code generation emitting a truncated array parameter; code with syntax errors earlier in the file that make tree-sitter's error recovery produce an array_type without an inner type node.

Related errors


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