{"record":{"id":"a5c4adb6674e8783","repo":"windmill-labs/windmill","slug":"error-setting-c-as-language-e","errorCode":null,"errorMessage":"Error setting c# as language: {e}","messagePattern":"Error setting c# as language: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"backend/parsers/windmill-parser-csharp/src/lib.rs","lineNumber":32,"sourceCode":"    pub is_async: bool,\n    pub is_public: bool,\n    pub returns_void: bool,\n    pub class_name: Option<String>,\n    pub main_sig: MainArgSignature,\n}\n\nfn csharp_param_default_value<'a>(def: Node<'a>, code: &str) -> Option<serde_json::Value> {\n    def.utf8_text(code.as_bytes())\n        .ok()\n        .and_then(|content| serde_json::from_str(content).ok())\n}\n\npub fn parse_csharp_sig_meta(code: &str) -> anyhow::Result<CsharpMainSigMeta> {\n    let mut parser = tree_sitter::Parser::new();\n    let language = tree_sitter_c_sharp::LANGUAGE;\n    parser\n        .set_language(&language.into())\n        .map_err(|e| anyhow!(\"Error setting c# as language: {e}\"))?;\n\n    // Parse code\n    let tree = parser.parse(code, None).expect(\"Failed to parse code\");\n    let root_node = tree.root_node();\n\n    // Traverse the AST to find the Main method signature\n    let main_sig = find_main_signature(root_node, code);\n    let auto_kind = if main_sig.is_none() {\n        Some(\"lib\".to_string())\n    } else {\n        None\n    };\n    let mut is_async = false;\n    let mut is_public = false;\n    let mut returns_void = false;\n    let mut class_name = None;\n\n    let mut args = vec![];","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-csharp/src/lib.rs#L14-L50","documentation":"This error comes from parse_csharp_sig_meta when the tree-sitter parser refuses to load the C# grammar via parser.set_language(). It wraps the underlying tree_sitter::LanguageError, which normally indicates a version mismatch between the tree_sitter runtime crate and the tree-sitter-c-sharp grammar crate, or a corrupted/incompatible grammar object. In practice it is almost never caused by user script content — it fires before any code is parsed.","triggerScenarios":"Calling parse_csharp_sig_meta (directly or via parse_csharp_signature) when the compiled tree-sitter runtime ABI version does not match the one tree-sitter-c-sharp was generated against, or when the Parser fails to accept the LANGUAGE binary. Any script-signature extraction on a C# script hits this path.","commonSituations":"A Cargo.lock drift or partial upgrade where tree_sitter was bumped but tree-sitter-c-sharp was not (or vice versa); building with mismatched feature flags across a workspace; mixing wasm and native builds of the grammar; stale build artifacts after a toolchain update.","solutions":["Run cargo update -p tree-sitter-c-sharp and cargo update -p tree-sitter together so both resolve to ABI-compatible versions, then cargo clean -p tree-sitter -p tree-sitter-c-sharp and rebuild","Check the tree-sitter LANGUAGE_VERSION/MIN_LANGUAGE_VERSION constants against the grammar crate version and pin a known-good pair in Cargo.toml","Delete stale target artifacts (cargo clean) and rebuild — ABI mismatches often persist via incremental caches","If building for wasm, confirm the grammar crate is compiled with the wasm-compatible feature set"],"exampleFix":"// before (Cargo.toml)\ntree-sitter = \"0.22\"\ntree-sitter-c-sharp = \"0.20\"\n// after (aligned versions)\ntree-sitter = \"0.22\"\ntree-sitter-c-sharp = \"0.22\"","handlingStrategy":"try-catch","validationCode":"// No user-side pre-check: the failure is environmental (crate ABI), not input-dependent.\n// CI check that catches it before deploy:\n// cargo test -p windmill-parser-csharp","typeGuard":null,"tryCatchPattern":"match parse_csharp_sig_meta(code) {\n    Ok(meta) => meta,\n    Err(e) if e.to_string().contains(\"Error setting c# as language\") => {\n        // dependency/ABI problem: report as build-environment issue, not script issue\n        bail!(\"parser build environment broken (tree-sitter ABI): {e}\")\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Pin tree-sitter and tree-sitter-c-sharp to ABI-compatible versions in Cargo.toml","Run the parser crate's unit tests in CI on every dependency bump","cargo clean after any tree-sitter family upgrade","Keep native and wasm builds on identical crate versions"],"tags":["rust","tree-sitter","dependency-mismatch"],"backgroundTag":"tree-sitter-language-abi-mismatch","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"}