{"record":{"id":"cbf6f47708dc3117","repo":"windmill-labs/windmill","slug":"failed-to-find-inner-type-of-nullable-type","errorCode":null,"errorMessage":"Failed to find inner type of nullable_type","messagePattern":"Failed to find inner type of nullable_type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-csharp/src/lib.rs","lineNumber":137,"sourceCode":"                Ok(\"decimal\") | Ok(\"System.Decimal\") => Ok(Typ::Float),\n                Ok(\"object\") => Ok(Typ::Object(ObjectType::new(None, Some(vec![])))), // TODO: Complete the object type\n                Ok(s) => Err(anyhow!(\"Unknown type `{s}`\")),\n                Err(e) => Err(anyhow!(\"Error getting type name: {}\", e)),\n            }\n        }\n        \"array_type\" => {\n            let new_typ_node = typ_node\n                .child_by_field_name(\"type\")\n                .ok_or(anyhow!(\"Failed to find inner type of array type\"))?;\n            Ok(Typ::List(Box::new(find_typ(new_typ_node, code)?)))\n        }\n        \"identifier\" => Ok(Typ::Unknown),\n        \"generic_name\" => Ok(Typ::Unknown),\n        \"pointer_type\" => Ok(Typ::Int),\n        \"nullable_type\" => {\n            let new_typ_node = typ_node\n                .child_by_field_name(\"type\")\n                .ok_or(anyhow!(\"Failed to find inner type of nullable_type\"))?;\n            Ok(find_typ(new_typ_node, code)?)\n        }\n        wc => Err(anyhow!(\n            \"Unexpected C# type node kind: {} for '{}'. This type is not handeled by Windmill, please open an issue if this seems to be an error\",\n            wc,\n            typ_node.utf8_text(code.as_bytes())?\n        )),\n    }\n}\n\nfn parse_csharp_typ<'a>(\n    param_node: Node<'a>,\n    code: &str,\n) -> anyhow::Result<(Option<String>, Typ, String)> {\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(\"\");","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-csharp/src/lib.rs#L119-L155","documentation":"For `nullable_type` nodes (C# `T?`), find_typ recursively resolves the inner type via child_by_field_name(\"type\"). If the inner type child is absent from the AST, it errors with this message. Like 803, it signals the parse tree did not have the expected structure for a nullable type.","triggerScenarios":"parse_csharp_sig_meta on a signature with `T?` parameters where the grammar produces a nullable_type node without the `type` field — e.g. `Main(int?)` parsed oddly, or a mismatched tree-sitter-c-sharp version.","commonSituations":"Scripts using nullable value types (`int?`, `bool?`, `DateTime?`) in nonstandard positions; tree-sitter grammar version drift changing nullable_type node shape; truncated source ending in `int?`.","solutions":["Rewrite the parameter as a plain (non-nullable) supported type, e.g. `static void Main(int? x)` becomes `static void Main(int x)`","Check tree-sitter-c-sharp version alignment and rebuild with a pinned compatible version","If nullability is required, model it via a default value or object parameter instead"],"exampleFix":"// before\nstatic void Main(int? maybeCount)\n// after\nstatic void Main(int count)","handlingStrategy":"try-catch","validationCode":"// Pre-check: avoid `T?` in Windmill main signatures; rewrite before deploying\nif main_signature_text.contains('?') {\n    // replace nullable params with plain types or default values before extraction\n}","typeGuard":null,"tryCatchPattern":"match parse_csharp_sig_meta(code) {\n    Ok(m) => m,\n    Err(e) if e.to_string().contains(\"nullable_type\") => {\n        bail!(\"nullable parameter in Main signature not supported — use a plain type or default value\")\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Avoid `T?` (nullable value types) in Windmill C# main signatures","Express optionality via default values or object parameters instead","Pin tree-sitter-c-sharp so nullable_type nodes keep the expected `type` field"],"tags":["csharp","ast","nullable-type","parser"],"backgroundTag":"malformed-ast-node","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"}