headroomlabs-ai/headroom · error · ValueError
Language '{language}' is not supported by tree-sitter. Suppo
Error message
Language '{language}' is not supported by tree-sitter. Supported: python, javascript, typescript, go, rust, java, c, cpp, csharp, php. Error: {e} What it means
Raised from the except block around parser construction in _get_parser: building the tree_sitter.Parser and binding get_language(language) failed for the requested name. The supported set is python, javascript, typescript, go, rust, java, c, cpp, csharp, php; anything else (or a grammar whose wheel is missing/broken) surfaces here with the underlying exception chained via 'Error: {e}'.
Source
Thrown at headroom/transforms/code_compressor.py:168
_tree_sitter_local.parsers = parsers
if language not in parsers:
try:
from tree_sitter import Parser
from tree_sitter_language_pack import get_language
parser = Parser()
# `language` is a validated runtime str; get_language types its arg
# as a Literal of supported names, which a dynamic str can't satisfy.
parser.language = get_language(language) # type: ignore[arg-type]
parsers[language] = parser
logger.debug(
"Loaded tree-sitter parser for %s (thread %s)",
language,
threading.current_thread().name,
)
except Exception as e:
raise ValueError(
f"Language '{language}' is not supported by tree-sitter. "
f"Supported: python, javascript, typescript, go, rust, java, c, cpp, csharp, php. "
f"Error: {e}"
) from e
return parsers[language]
def is_tree_sitter_available() -> bool:
"""Check if tree-sitter is installed and available.
Returns:
True if tree-sitter-languages package is installed.
"""
return _check_tree_sitter_available()
def is_tree_sitter_loaded() -> bool:View on GitHub (pinned to 322425c43b)
Solutions
- Use one of the supported names exactly: python, javascript, typescript, go, rust, java, c, cpp, csharp, php.
- Check the chained 'Error:' suffix — if it names a missing grammar module, reinstall the grammar pack (pip install --force-reinstall tree-sitter-language-pack).
- For unsupported languages, route the content through the plain-text compressor instead.
Example fix
# before
parser = _get_parser("ts") # ValueError: not supported
# after
_LANGUAGE_ALIASES = {"ts": "typescript", "py": "python", "c++": "cpp"}
parser = _get_parser(_LANGUAGE_ALIASES.get(lang, lang)) Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {"python","javascript","typescript","go","rust","java","c","cpp","csharp","php"}
if language not in SUPPORTED:
language = None # plain-text path Type guard
def is_supported_ts_language(lang: str) -> bool:
return lang in {"python","javascript","typescript","go","rust","java","c","cpp","csharp","php"} Try / catch
try:
parser = _get_parser(language)
except ValueError as e:
if "not supported by tree-sitter" in str(e):
parser = None
else:
raise Prevention
- Normalize language aliases (ts->typescript) before calling.
- Validate language names against the supported list at config load.
- Read the chained 'Error:' text to distinguish missing grammar wheels from bad names.
When it happens
Trigger: Calling _get_parser with a language outside the supported list (e.g. 'ruby', 'kotlin', 'perl' would be caught earlier by quarantine), or a supported name whose grammar package is not installed/broken so get_language raises.
Common situations: Sending Ruby/Scala/Lua files into code-aware compression; a partially installed tree-sitter-language-pack where one grammar wheel failed; a typo in a config language key ('ts' instead of 'typescript').
Related errors
- Language '{language}' is quarantined for code-aware compress
- invalid pipeline config TOML: {0}
- recommendations file not found: {0}
- bedrock_eventstream_parse_failed
- items_json must be JSON: {e}
AI-assisted analysis of headroomlabs-ai/headroom@322425c43b (2026-08-15).
Data as JSON: /api/errors/b7ab5f24c2a22afe.
Report an issue: GitHub.