{"record":{"id":"702687ef49143ead","repo":"windmill-labs/windmill","slug":"error-getting-type-name","errorCode":null,"errorMessage":"Error getting type name: {}","messagePattern":"Error getting type name: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-java/src/lib.rs","lineNumber":112,"sourceCode":"\nfn find_typ<'a>(typ_node: Node<'a>, code: &str) -> anyhow::Result<(Typ, Option<Value>)> {\n    let null = Some(serde_json::Value::Null);\n    let res = match typ_node.kind() {\n        #[rustfmt::skip]\n        \"type_identifier\" => {\n            match typ_node.utf8_text(code.as_bytes()) {\n                Ok(\"String\")      => (Typ::Str(None), null),\n                Ok(\"Byte\")        => (Typ::Bytes, null),\n                Ok(\"Short\")       => (Typ::Int, null),\n                Ok(\"Integer\")     => (Typ::Int, null),\n                Ok(\"Long\")        => (Typ::Int, null),\n                Ok(\"Float\")       => (Typ::Float, null),\n                Ok(\"Double\")      => (Typ::Float, null),\n                Ok(\"Boolean\")     => (Typ::Bool, null),\n                Ok(\"Character\")   => (Typ::Str(None), null),\n                Ok(\"Object\")      => (Typ::Object(ObjectType::new(None, Some(vec![]))),null), // TODO: Complete the object type\n                Ok(s)       => bail!(\"Unknown type `{s}`\"),\n                Err(e) => bail!(\"Error getting type name: {}\", e),\n            }\n        }\n        #[rustfmt::skip]\n        \"integral_type\" => {\n            match typ_node.utf8_text(code.as_bytes()) {\n                Ok(\"byte\")   => (Typ::Bytes, None),\n                Ok(\"short\")  => (Typ::Int, None),\n                Ok(\"int\")    => (Typ::Int, None),\n                Ok(\"long\")   => (Typ::Int, None),\n                Ok(\"char\")   => (Typ::Str(None), None),\n                Ok(s)  => bail!(\"Unknown type `{s}`\"),\n                Err(e) => bail!(\"Error getting type name: {}\", e),\n            }\n        }\n        \"floating_point_type\" => {\n            match typ_node.utf8_text(code.as_bytes()) {\n                Ok(\"float\") => (Typ::Float, None),\n                Ok(\"double\") => (Typ::Float, None),","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-java/src/lib.rs#L94-L130","documentation":"In the same Java parser allowlist dispatch, the `Err(e)` arm fires when `typ_node.utf8_text(code.as_bytes())` itself fails — i.e. the tree-sitter node's byte range cannot be extracted from the source (invalid UTF-8 or a malformed node range). The parser bails with 'Error getting type name: {e}' instead of a type-name problem.","triggerScenarios":"Calling find_typ on a Java type node whose source bytes are not valid UTF-8 (e.g. a Java file with non-UTF-8 encoding containing exotic characters in/around a type), or a corrupted/inconsistent tree-sitter parse where the node range exceeds the input.","commonSituations":"Java sources saved with windows-1252/latin-1 encoding; files with BOM or binary content sneaking into script storage; parser version drift producing nodes outside the source buffer.","solutions":["Re-save the Java script file as UTF-8 (without BOM) and re-upload/re-sync.","Strip non-ASCII characters from type declarations in the script.","Update the tree-sitter-java grammar / windmill-parser-java crate so node ranges match the current grammar version.","If persisting scripts through tooling, ensure the pipeline reads/writes files as UTF-8 strings, not raw bytes."],"exampleFix":"// before\n$ iconv -f windows-1252 MyScript.java > fixed.java  # still not UTF-8-safe in places\n// after\n$ iconv -f windows-1252 -t UTF-8 MyScript.java > fixed.java","handlingStrategy":"validation","validationCode":"# ensure the Java source is valid UTF-8 before upload\nfile MyScript.java\ndatamash check 2>/dev/null || true\niconv -f UTF-8 -t UTF-8 MyScript.java > /dev/null || { echo \"not valid UTF-8\"; exit 1; }","typeGuard":"function isValidUtf8(bytes: Uint8Array): boolean {\n  try { new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes); return true; }\n  catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["Configure editors to save as UTF-8 (no BOM) for all script files.","Run `iconv -f UTF-8 -t UTF-8` as a pre-commit/CI check on Java scripts.","Keep tree-sitter-java and windmill-parser-java versions in lockstep."],"tags":["java","parser","encoding","utf-8","tree-sitter"],"backgroundTag":"invalid-source-encoding","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"}