{"record":{"id":"19f9c6abb79e0b54","repo":"oraios/serena","slug":"body-line-numbers-could-not-be-determined-for-sel","errorCode":null,"errorMessage":"Body line numbers could not be determined for {self.get_name_path()}","messagePattern":"Body line numbers could not be determined for (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/serena/symbol.py","lineNumber":317,"sourceCode":"        return PositionInFile(line=start_pos[\"line\"], col=start_pos[\"character\"])\n\n    def get_body_end_position(self) -> PositionInFile | None:\n        end_pos = self.body_end_position\n        if end_pos is None:\n            return None\n        return PositionInFile(line=end_pos[\"line\"], col=end_pos[\"character\"])\n\n    def get_body_line_numbers(self) -> tuple[int | None, int | None]:\n        start_pos = self.body_start_position\n        end_pos = self.body_end_position\n        start_line = start_pos[\"line\"] if start_pos else None\n        end_line = end_pos[\"line\"] if end_pos else None\n        return start_line, end_line\n\n    def get_body_line_numbers_or_raise(self) -> tuple[int, int]:\n        start_line, end_line = self.get_body_line_numbers()\n        if start_line is None or end_line is None:\n            raise ValueError(f\"Body line numbers could not be determined for {self.get_name_path()}\")\n        return start_line, end_line\n\n    @property\n    def line(self) -> int | None:\n        \"\"\"\n        :return: the line in which the symbol identifier is defined.\n        \"\"\"\n        if \"selectionRange\" in self.symbol_root:\n            return self.symbol_root[\"selectionRange\"][\"start\"][\"line\"]\n        else:\n            # line is expected to be undefined for some types of symbols (e.g. SymbolKind.File)\n            return None\n\n    @property\n    def column(self) -> int | None:\n        if \"selectionRange\" in self.symbol_root:\n            return self.symbol_root[\"selectionRange\"][\"start\"][\"character\"]\n        else:","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/symbol.py#L299-L335","documentation":"get_body_line_numbers_or_raise converts the body start/end positions to 1-based line numbers and raises when either is None. The `apply` tool relies on it to print/return precise line ranges, so symbols without resolvable body ranges abort the operation.","triggerScenarios":"Running the apply (present_instructions / body edit) tool on a symbol whose get_body_line_numbers() returns (None, ...) — e.g. body-less constructs or language servers that don't supply selection ranges.","commonSituations":"Applying edits to imports, type aliases or expressions; language servers with incomplete range support for the active language; symbol looked up from a reference rather than its definition.","solutions":["Fall back to get_body_line_numbers() and handle None explicitly in your own tooling","Only apply to symbols with full body ranges (check get_body_start_position()/get_body_end_position() first)","Switch/upgrade the language server for the file's language so ranges are populated"],"exampleFix":"// before\nstart, end = symbol.get_body_line_numbers_or_raise()\n// after\nstart, end = symbol.get_body_line_numbers()\nif start is None or end is None:\n    skip_or_relocate(symbol)","handlingStrategy":"type-guard","validationCode":"start, end = symbol.get_body_line_numbers()\nif start is None or end is None:\n    raise SkipSymbol(f\"line numbers unavailable for {symbol.get_name_path()}\")","typeGuard":"def has_line_numbers(symbol) -> bool:\n    s, e = symbol.get_body_line_numbers()\n    return s is not None and e is not None","tryCatchPattern":"try:\n    result = tool.apply(...)\nexcept ValueError as e:\n    if \"Body line numbers could not be determined\" in str(e):\n        fallback_to_manual_range(symbol)\n    else:\n        raise","preventionTips":["Verify the language server reports full ranges for the target language","Skip module-level/alias symbols when using the apply tool","Use the lenient get_body_line_numbers() in custom tooling and handle None"],"tags":["serena","symbols","line-numbers"],"backgroundTag":"symbol-body-position-undefined","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}