{"record":{"id":"13c332e73835d8a7","repo":"oraios/serena","slug":"no-symbols-found-in-target-file-target-file","errorCode":null,"errorMessage":"No symbols found in target file {target_file}","messagePattern":"No symbols found in target file (.+?)","errorType":"exception","errorClass":"_HealthCheckFailure","httpStatus":null,"severity":"error","filePath":"src/serena/cli.py","lineNumber":987,"sourceCode":"                            break\n                    except (OSError, FileNotFoundError):\n                        continue\n\n                if not target_file:\n                    raise ProjectCommands._HealthCheckFailure(\"No analyzable files found\")\n\n                # Get tools from agent\n                overview_tool = agent.get_tool(GetSymbolsOverviewTool)\n                find_symbol_tool = agent.get_tool(FindSymbolTool)\n                find_refs_tool = agent.get_tool(FindReferencingSymbolsTool)\n\n                # Test 1: Get symbols overview\n                log.info(\"Testing GetSymbolsOverviewTool on file: %s\", target_file)\n                overview_data = agent.execute_task(lambda: overview_tool.get_symbol_overview(target_file))\n                log.info(f\"GetSymbolsOverviewTool returned: {overview_data}\")\n\n                if not overview_data:\n                    raise ProjectCommands._HealthCheckFailure(f\"No symbols found in target file {target_file}\")\n\n                # Extract suitable symbol (prefer class or function over variables)\n                preferred_kinds = {SymbolKind.Class.name, SymbolKind.Function.name, SymbolKind.Method.name, SymbolKind.Constructor.name}\n                selected_symbol = None\n                for symbol in overview_data:\n                    if symbol.get(\"kind\") in preferred_kinds:\n                        selected_symbol = symbol\n                        break\n\n                # If no preferred symbol found, use first available\n                if not selected_symbol:\n                    selected_symbol = overview_data[0]\n                    log.info(\"No class or function found, using first available symbol\")\n\n                symbol_name = selected_symbol[\"name\"]\n                symbol_kind = selected_symbol[\"kind\"]\n                log.info(\"Using symbol for testing: %s (kind: %s)\", symbol_name, symbol_kind)\n","sourceCodeStart":969,"sourceCodeEnd":1005,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/cli.py#L969-L1005","documentation":"Health check step 1 runs GetSymbolsOverviewTool on the chosen target file. If the language server returns an empty symbol list, serena raises `_HealthCheckFailure` because subsequent symbol-lookup tests cannot proceed. This indicates the language server is up but not producing symbols for that file.","triggerScenarios":"`serena project health-check` selected a target file whose overview returns an empty list — e.g. a file with no classes/functions/methods/variables the LS reports, an empty file, or an LS that fails silently to parse it.","commonSituations":"Target file is empty or only comments/imports; the language server doesn't support that file type; the file is a config/markup file that slipped through the analyzable-file search; a broken LS install returning no symbols.","solutions":["Ensure the project contains a real source file with at least one class, function, or method.","Verify the language server for the project language is installed and starts without errors (check serena logs).","Re-run `serena project index` to refresh the symbol cache, then re-run the health check.","Try the health check on a known-good file in the project."],"exampleFix":"// before (target file is empty stubs.py)\n# (nothing in stubs.py)\n// after\n# stubs.py\ndef hello():\n    return 'hi'\n# re-run: serena project health-check","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\ntarget = Path('main.py')\ncontent = target.read_text()\nif not any(ln.strip() and not ln.strip().startswith(('#', '//', 'import', 'from')) for ln in content.splitlines()):\n    raise SystemExit('Target file has no code; pick a file with real definitions')","typeGuard":null,"tryCatchPattern":"try:\n    run(['serena', 'project', 'health-check'], check=True)\nexcept subprocess.CalledProcessError as e:\n    if 'No symbols found' in e.stderr:\n        print('Language server returned no symbols; check LS installation/logs')","preventionTips":["Health-check projects whose entry files contain real classes/functions, not just comments or empty stubs.","Verify the language server for the project language starts cleanly before running checks.","Check serena logs for LS errors when the check mentions empty overviews."],"tags":["cli","health-check","language-server"],"backgroundTag":"language-server-empty-symbols","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}