oraios/serena · error · ValueError
Cannot extract symbols from file {relative_path}. Active lan
Error message
Cannot extract symbols from file {relative_path}. Active language servers: {[l.value for l in self.agent.get_active_language_server_ids()]} What it means
Even for an existing file, the active language server(s) may not be able to analyze its type. When symbol_retriever.can_analyze_file returns False, the tool raises ValueError listing the currently active language servers so the caller can see the mismatch.
Source
Thrown at src/serena/tools/symbol_tools.py:109
return self._limit_length(result_json_str, max_answer_chars, shortened_result_factories=shortened_results)
def get_symbol_overview(self, relative_path: str, depth: int = 0) -> list[LanguageServerSymbol.OutputDict]:
"""
:param relative_path: relative path to a source file
:param depth: the depth up to which descendants shall be retrieved
:return: a list of symbol dictionaries representing the symbol overview of the file
"""
symbol_retriever = self.create_language_server_symbol_retriever()
# The symbol overview is capable of working with both files and directories,
# but we want to ensure that the user provides a file path.
file_path = os.path.join(self.project.project_root, relative_path)
if not os.path.exists(file_path):
raise FileNotFoundError(f"File or directory {relative_path} does not exist in the project.")
if os.path.isdir(file_path):
raise ValueError(f"Expected a file path, but got a directory path: {relative_path}. ")
if not symbol_retriever.can_analyze_file(relative_path):
raise ValueError(
f"Cannot extract symbols from file {relative_path}. Active language servers: {[l.value for l in self.agent.get_active_language_server_ids()]}"
)
symbols = symbol_retriever.get_symbol_overview(relative_path)[relative_path]
def child_inclusion_predicate(s: LanguageServerSymbol) -> bool:
return not s.is_low_level()
symbol_dicts = []
for symbol in symbols:
symbol_dicts.append(
symbol.to_dict(
name_path=False,
name=True,
depth=depth,
kind=True,
relative_path=False,
location=False,View on GitHub (pinned to 7fcbca7e62)
Solutions
- Point the tool at a source file of a language with an active language server
- Configure/enable the language server for that file type in serena config
- Check logs for language-server startup failures and fix them, then retry
Example fix
// before
get_symbol_overview.apply(relative_path='README.md')
// ValueError: Cannot extract symbols...
// after
if file.suffix in ('.py', '.ts', '.go', ...): # LS-supported
get_symbol_overview.apply(relative_path=str(file)) Defensive patterns
Strategy: validation
Validate before calling
supported_exts = {e for ls in agent.get_active_language_server_ids()
for e in EXTENSIONS_FOR[ls]} # e.g. py, ts, go...
if Path(relative_path).suffix not in supported_exts:
raise SkipToolCall(f'{relative_path} not analyzable') Type guard
def analyzable(rel: str) -> bool:
return Path(rel).suffix in SUPPORTED_SUFFIXES # from active LS config Try / catch
try:
overview = symbol_tool.get_symbol_overview(relative_path=rel)
except ValueError as e:
if 'Cannot extract symbols' in str(e):
overview = text_based_fallback(rel) # grep/AST without LS
else:
raise Prevention
- Only point symbol tools at source files of languages with active language servers
- Verify language server startup in logs before using symbol tools
- Keep config/data files (json, md, yaml) out of symbol queries
When it happens
Trigger: Requesting symbols from a file with an extension not covered by any active language server (e.g. a .json, .txt, or a language whose LS isn't enabled); a language server failed to start so its languages are inactive.
Common situations: Pointing symbol tools at config/docs files; missing language server configuration for the project's language; LS crashed at startup so can_analyze_file fails for otherwise supported files.
Related errors
- No symbol declaration found at the location of the regex mat
- FindSymbolTool returned no results
- Invalid language server: '{orig_language_str}'.\nValid value
- The language server manager is not initialized, indicating a
- name_path_pattern must not be empty or contain only wildcard
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/0c909213c760ec68.
Report an issue: GitHub.