{"record":{"id":"598430963f2f9920","repo":"oraios/serena","slug":"no-symbol-declaration-found-at-the-location-of-the","errorCode":null,"errorMessage":"No symbol declaration found at the location of the regex match. Location: {relative_path}:{coords.line}:{coords.col}.","messagePattern":"No symbol declaration found at the location of the regex match\\. Location: (.+?):(.+?):(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/serena/tools/symbol_tools.py","lineNumber":453,"sourceCode":"            coords = find_text_coordinates(content, regex, require_unique=True)\n            assert coords is not None\n        else:\n            symbol = symbol_retriever.find_unique(name_path_pattern=containing_symbol_name_path, within_relative_path=relative_path)\n            body_line_numers = symbol.get_body_line_numbers_or_raise()\n            content = editor.read_file(relative_path, lines=body_line_numers)\n            coords = find_text_coordinates(content, regex, require_unique=True)\n            assert coords is not None\n            coords.line += body_line_numers[0]\n\n        # retrieve declaration\n        defining_symbol = symbol_retriever.find_declaration(\n            relative_file_path=relative_path,\n            line=coords.line,\n            column=coords.col,\n            include_body=include_body,\n        )\n        if defining_symbol is None:\n            raise ValueError(\n                f\"No symbol declaration found at the location of the regex match. Location: {relative_path}:{coords.line}:{coords.col}.\"\n            )\n\n        # create output\n        symbol_dict = self._defining_symbol_to_result_dict(\n            symbol_retriever,\n            defining_symbol,\n            include_body,\n            include_info,\n        )\n        result = self._to_json(symbol_dict)\n        return result\n\n    @staticmethod\n    def _defining_symbol_to_result_dict(\n        symbol_retriever: Any,\n        defining_symbol: LanguageServerSymbol,\n        include_body: bool,","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/tools/symbol_tools.py#L435-L471","documentation":"find_symbol by regex/coordinate flow locates a regex match in a file, then asks the language server for the symbol declaration at that position. If the language server reports no defining symbol at the match's line/column, the tool raises this ValueError.","triggerScenarios":"The regex matches text that is not a symbol declaration/usage the LS recognizes (comments, strings, keywords, generated code without LS support); the match's coordinates are stale after the file changed; the file's language has no active language server.","commonSituations":"Regex like 'def |class ' catching decorators or docstrings; file edited between pattern search and symbol lookup so line:col now lands elsewhere; searching in a file type the LS can't index.","solutions":["Tighten the regex so matches land on actual symbol identifiers/declarations","Re-run the search immediately before symbol lookup so coordinates are current","Verify the file is in an LS-supported language and the symbol is a real declaration, not a comment/string","Fall back to find_symbol with a name_path_pattern instead of coordinate-based lookup"],"exampleFix":"// before\npattern = 'def'  # matches the word anywhere, incl. comments\n// ValueError: No symbol declaration found at ...\n\n// after\npattern = r'def\\s+my_function\\b'  # match lands on the actual symbol","handlingStrategy":"try-catch","validationCode":"m = regex.search(text)\nline = text.count('\\n', 0, m.start()) + 1\ncol = m.start() - text.rfind('\\n', 0, m.start())\n# ensure match lands on an identifier, not comments/strings:\nif text[m.start():m.end()] not in identifiers_of_file(text):\n    raise SkipToolCall('regex match is not a symbol')","typeGuard":null,"tryCatchPattern":"try:\n    sym = find_symbol_by_regex_tool.apply(regex=pattern, ...)\nexcept ValueError as e:\n    if 'No symbol declaration found' in str(e):\n        sym = find_symbol_tool.apply(name_path_pattern=extract_identifier(pattern))\n    else:\n        raise","preventionTips":["Anchor regexes to symbol declarations (e.g. r'def\\\\s+name\\\\b'), not bare keywords","Re-read the file right before coordinate lookup to avoid stale positions","Prefer name_path_pattern lookup over regex-coordinate lookup when possible"],"tags":["python","regex","symbols","language-server"],"backgroundTag":"symbol-not-found-at-location","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}