{"record":{"id":"db44c9f928fa4231","repo":"oraios/serena","slug":"start-line-must-be-non-negative-got-start-line","errorCode":null,"errorMessage":"start_line must be non-negative, got {start_line}","messagePattern":"start_line must be non-negative, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/ls.py","lineNumber":818,"sourceCode":"        end_line: int,\n        min_severity: int,\n    ) -> list[ls_types.Diagnostic]:\n        diagnostics = [d for d in diagnostics if cls._diagnostic_matches_range(d, start_line, end_line)]\n        diagnostics = [d for d in diagnostics if cls._diagnostic_matches_min_severity(d, min_severity)]\n        return diagnostics\n\n    def _validate_text_document_diagnostics_request(\n        self,\n        relative_file_path: str,\n        start_line: int,\n        end_line: int,\n        min_severity: int,\n    ) -> str:\n        if not self.server_started:\n            log.error(\"request_text_document_diagnostics called before Language Server started\")\n            raise SolidLSPException(\"Language Server not started\")\n        if start_line < 0:\n            raise ValueError(f\"start_line must be non-negative, got {start_line}\")\n        if end_line != -1 and end_line < start_line:\n            raise ValueError(f\"end_line must be -1 or >= start_line, got {end_line} < {start_line}\")\n        if min_severity not in {1, 2, 3, 4}:\n            raise ValueError(f\"min_severity must be one of 1, 2, 3, 4, got {min_severity}\")\n        return pathlib.Path(str(PurePath(self.repository_root_path, relative_file_path))).as_uri()\n\n    def get_published_diagnostics_generation(self, relative_file_path: str) -> int:\n        \"\"\"\n        Get the generation number for the latest published diagnostics of a file.\n\n        :param relative_file_path: The relative path of the file.\n        :return: the generation number, or ``-1`` if none were published yet.\n        \"\"\"\n        uri = pathlib.Path(str(PurePath(self.repository_root_path, relative_file_path))).as_uri()\n        return self._get_published_diagnostics_generation(uri)\n\n    def get_cached_published_text_document_diagnostics(\n        self,","sourceCodeStart":800,"sourceCodeEnd":836,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/ls.py#L800-L836","documentation":"Before querying diagnostics, SolidLSP validates arguments in _validate_text_document_diagnostics_request. A negative start_line is invalid because LSP positions are 0-based line numbers, so a ValueError('start_line must be non-negative, ...') is raised.","triggerScenarios":"Calling request_text_document_diagnostics / request_published_text_document_diagnostics / get_cached_published_text_document_diagnostics with start_line < 0 (e.g. -1 used as a sentinel, or an unsigned conversion bug).","commonSituations":"Passing -1 to mean 'whole file' (the sentinel is end_line, not start_line); converting unsigned LSP positions with signed overflow; uninitialized/default-initialized position variables.","solutions":["Pass a 0-based, non-negative start_line (first line is 0)","Use end_line=-1 to indicate 'to end of file' instead of a negative start_line","Validate/clamp user- or computed-provided line numbers before calling"],"exampleFix":"// before\nls.request_text_document_diagnostics(\"src/a.py\", -1, -1, 3)\n// after\nls.request_text_document_diagnostics(\"src/a.py\", 0, -1, 3)","handlingStrategy":"validation","validationCode":"assert isinstance(start_line, int) and start_line >= 0, f\"start_line must be >= 0, got {start_line}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember LSP lines are 0-based; first line is 0","Use end_line=-1 (not negative start_line) for 'whole file'","Clamp computed positions: start_line = max(0, start_line)"],"tags":["validation","diagnostics","arguments","lsp"],"backgroundTag":"invalid-argument-value","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}