{"record":{"id":"ae9a5f750def6113","repo":"oraios/serena","slug":"symbol-location-does-not-contain-a-valid-position","errorCode":null,"errorMessage":"Symbol location does not contain a valid position in a file","messagePattern":"Symbol location does not contain a valid position in a file","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/serena/symbol.py","lineNumber":857,"sourceCode":"        exclude_kinds: Sequence[SymbolKind] | None = None,\n    ) -> list[ReferenceInLanguageServerSymbol]:\n        \"\"\"\n        Find all symbols that reference the symbol at the given location.\n\n        :param symbol_location: the location of the symbol for which to find references.\n            Does not need to include an end_line, as it is unused in the search.\n        :param include_body: whether to include the body of all symbols in the result.\n            Not recommended, as the referencing symbols will often be files, and thus the bodies will be very long.\n            Note: you can filter out the bodies of the children if you set include_children_body=False\n            in the to_dict method.\n        :param include_kinds: an optional sequence of ints representing the LSP symbol kind.\n            If provided, only symbols of the given kinds will be included in the result.\n        :param exclude_kinds: If provided, symbols of the given kinds will be excluded from the result.\n            Takes precedence over include_kinds.\n        :return: a list of symbols that reference the given symbol\n        \"\"\"\n        if not symbol_location.has_position_in_file():\n            raise ValueError(\"Symbol location does not contain a valid position in a file\")\n        assert symbol_location.relative_path is not None\n        assert symbol_location.line is not None\n        assert symbol_location.column is not None\n        lang_server = self.get_language_server(symbol_location.relative_path)\n        references = lang_server.request_referencing_symbols(\n            relative_file_path=symbol_location.relative_path,\n            line=symbol_location.line,\n            column=symbol_location.column,\n            include_imports=False,\n            include_self=False,\n            include_body=include_body,\n            include_file_symbols=True,\n        )\n\n        if include_kinds is not None:\n            references = [s for s in references if s.symbol[\"kind\"] in include_kinds]\n\n        if exclude_kinds is not None:","sourceCodeStart":839,"sourceCodeEnd":875,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/symbol.py#L839-L875","documentation":"find_referencing_symbols_by_location needs an absolute position (file + line + column) to ask the language server for references. If the passed LanguageServerSymbolLocation lacks a position in file, it raises this ValueError instead of sending a malformed request.","triggerScenarios":"Constructing a location from a symbol whose position is None (e.g. module-level symbols, references without ranges) and passing it to find_referencing_symbols/get_symbol_diagnostics_by_location.","commonSituations":"Using a location obtained from a stale or non-definitional symbol; hand-building a LanguageServerSymbolLocation from search results that omitted line/column; language servers that return no selection range for certain constructs.","solutions":["Check symbol_location.has_position_in_file() before calling and skip or re-resolve symbols without positions","Obtain the location from a full symbol lookup (find_unique) rather than partial search data","Supply line/column explicitly if you know the definition site"],"exampleFix":"// before\nrefs = mgr.find_referencing_symbols_by_location(loc)  # loc has no position\n// after\nif loc.has_position_in_file():\n    refs = mgr.find_referencing_symbols_by_location(loc)","handlingStrategy":"type-guard","validationCode":"if not symbol_location.has_position_in_file():\n    raise SkipSymbol(\"location lacks line/column\")","typeGuard":"def is_located(loc) -> bool:\n    return loc.has_position_in_file() and loc.relative_path is not None","tryCatchPattern":"try:\n    refs = mgr.find_referencing_symbols_by_location(loc)\nexcept ValueError as e:\n    if \"valid position in a file\" in str(e):\n        refs = re_resolve_and_find_refs(loc)\n    else:\n        raise","preventionTips":["Derive locations from find_unique/full symbol lookups, not partial search results","Skip references lookups for symbols without positions","Confirm the language server populates selection ranges for the language in use"],"tags":["serena","references","location"],"backgroundTag":"invalid-symbol-location","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}