Skip to content

Skip invalid tree-sitter queries in repo map generation#4920

Open
biefan wants to merge 1 commit intoAider-AI:mainfrom
biefan:fix-repomap-queryerror
Open

Skip invalid tree-sitter queries in repo map generation#4920
biefan wants to merge 1 commit intoAider-AI:mainfrom
biefan:fix-repomap-queryerror

Conversation

@biefan
Copy link
Copy Markdown

@biefan biefan commented Mar 14, 2026

Summary

Prevent repo map generation from crashing when a tree-sitter tag query cannot be compiled for a file.

Problem

RepoMap.get_tags_raw() currently lets tree_sitter.QueryError bubble out of Query(language, query_scm). When a .scm query and the installed parser are out of sync, a single file can crash repo map generation for the entire run.

Root cause

get_tags_raw() already treats parser initialization failures as file-level skips, but query compilation failures were not handled the same way. That meant an invalid query was not isolated to the file that triggered it.

Fix

  • catch QueryError around query compilation/capture execution
  • skip the affected file the same way parser setup failures are skipped
  • add a regression test that patches Query(...) to fail and verifies get_repo_map() still returns a repo map instead of crashing

Validation

  • ./.venv311/bin/python -m pytest tests/basic/test_repomap.py -q
  • ./.venv311/bin/python -m flake8 aider/repomap.py tests/basic/test_repomap.py

Fixes #4919.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 14, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uncaught QueryError in repomap.py line 302

2 participants