{"record":{"id":"b51446f853245441","repo":"headroomlabs-ai/headroom","slug":"language-language-is-quarantined-for-code-awar","errorCode":null,"errorMessage":"Language '{language}' is quarantined for code-aware compression.","messagePattern":"Language '(.+?)' is quarantined for code-aware compression\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"headroom/transforms/code_compressor.py","lineNumber":137,"sourceCode":"\n    We use the stock ``tree_sitter.Parser`` (which returns standard\n    ``tree_sitter.Node`` / ``tree_sitter.Tree`` with property access) and\n    set its language via ``tree_sitter_language_pack.get_language()``.\n    Storing one parser per (thread, language) satisfies the ``unsendable``\n    contract with negligible extra memory.\n\n    Args:\n        language: Language name (e.g., 'python', 'javascript').\n\n    Returns:\n        Configured ``tree_sitter.Parser`` bound to the current thread.\n\n    Raises:\n        ImportError: If tree-sitter is not installed.\n        ValueError: If language is not supported.\n    \"\"\"\n    if language in _UNSAFE_TREE_SITTER_LANGUAGES:\n        raise ValueError(f\"Language '{language}' is quarantined for code-aware compression.\")\n    # NOTE: guard on importability (not _check_tree_sitter_available), because\n    # _check_tree_sitter_available now performs a real end-to-end parse via\n    # _get_parser; guarding on it here would recurse.\n    if not _tree_sitter_importable():\n        raise ImportError(\n            \"tree-sitter is not installed. Install with: pip install headroom-ai[code]\\n\"\n            \"This adds ~50MB for tree-sitter grammars.\"\n        )\n\n    parsers: dict[str, Any] | None = getattr(_tree_sitter_local, \"parsers\", None)\n    if parsers is None:\n        parsers = {}\n        _tree_sitter_local.parsers = parsers\n\n    if language not in parsers:\n        try:\n            from tree_sitter import Parser\n            from tree_sitter_language_pack import get_language","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/transforms/code_compressor.py#L119-L155","documentation":"Raised by _get_parser when the requested language name is in the hardcoded quarantine set _UNSAFE_TREE_SITTER_LANGUAGES (currently frozenset({\"perl\"}) at code_compressor.py:106). These grammars are known to hang or crash the tree-sitter parser, so Headroom refuses to build a code-aware parser for them before doing anything else. It is a ValueError thrown deliberately ahead of any parsing work.","triggerScenarios":"Calling _get_parser('perl') (or any future language added to _UNSAFE_TREE_SITTER_LANGUAGES) — i.e. routing Perl source into code-aware compression that eventually requests a tree-sitter parser for it.","commonSituations":"Pointing Headroom's code-aware compression at a Perl codebase, or a config that maps .pl/.pm files to the code compressor. The grammar is quarantined rather than merely unsupported because the perl grammar causes real runtime failures, not just bad parses.","solutions":["Exclude Perl from code-aware compression (let it fall through to the generic/text compression path) — do not request a tree-sitter parser for it.","If you control the input, pre-filter language=\"perl\" before calling the compressor API.","Do not attempt to work around by renaming the language; the quarantine exists because the grammar itself is unsafe."],"exampleFix":"# before\nparser = _get_parser(\"perl\")  # ValueError: quarantined\n\n# after\nfrom headroom.transforms.code_compressor import _UNSAFE_TREE_SITTER_LANGUAGES\nif language in _UNSAFE_TREE_SITTER_LANGUAGES:\n    text = compress_as_plain_text(source)  # non-code-aware path\nelse:\n    parser = _get_parser(language)","handlingStrategy":"validation","validationCode":"from headroom.transforms.code_compressor import _UNSAFE_TREE_SITTER_LANGUAGES\nif language in _UNSAFE_TREE_SITTER_LANGUAGES:\n    language = None  # route to plain-text compression","typeGuard":"def is_safe_treesitter_language(lang: str) -> bool:\n    return lang not in _UNSAFE_TREE_SITTER_LANGUAGES","tryCatchPattern":"try:\n    parser = _get_parser(language)\nexcept ValueError as e:\n    if \"quarantined\" in str(e):\n        parser = None  # fall back to non-code-aware compression\n    else:\n        raise","preventionTips":["Filter languages through the quarantine set before requesting parsers.","Keep Perl out of any config that enables code-aware compression.","Watch the frozenset contents on upgrades — the quarantine list can grow."],"tags":["tree-sitter","language-support","validation","code-compression"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}