{"record":{"id":"416fe35ffbce3d44","repo":"oraios/serena","slug":"min-severity-must-be-one-of-1-2-3-4-got-min-s","errorCode":null,"errorMessage":"min_severity must be one of 1, 2, 3, 4, got {min_severity}","messagePattern":"min_severity must be one of 1, 2, 3, 4, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/ls.py","lineNumber":822,"sourceCode":"        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,\n        relative_file_path: str,\n        start_line: int = 0,\n        end_line: int = -1,\n        min_severity: int = 4,","sourceCodeStart":804,"sourceCodeEnd":840,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/ls.py#L804-L840","documentation":"The min_severity argument to diagnostics requests must be one of the LSP diagnostic severity codes 1 (Error), 2 (Warning), 3 (Information), 4 (Hint). Any other value raises a ValueError listing the allowed set.","triggerScenarios":"Calling request_text_document_diagnostics / request_published_text_document_diagnostics / get_cached_published_text_document_diagnostics with min_severity outside {1,2,3,4}, e.g. 0, 5, or a string.","commonSituations":"Using 0 as 'all severities' instead of 4; passing an enum object instead of its int value; off-by-one assumptions about severity ordering.","solutions":["Pass an integer 1-4 inclusive (1=Error, 2=Warning, 3=Information, 4=Hint)","Use 4 if you want the least restrictive filter (include everything)","Convert enum values to int before passing"],"exampleFix":"// before\nls.request_text_document_diagnostics(\"src/a.py\", 0, -1, 0)  # 0 invalid\n// after\nls.request_text_document_diagnostics(\"src/a.py\", 0, -1, 4)  # 4 = include hints and above","handlingStrategy":"validation","validationCode":"VALID_SEVERITIES = {1, 2, 3, 4}\nif min_severity not in VALID_SEVERITIES:\n    raise ValueError(f\"min_severity must be one of {sorted(VALID_SEVERITIES)}, got {min_severity}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use an IntEnum for DiagnosticSeverity and pass .value","Remember 4 (Hint) is the least restrictive filter, not 0","Cast enums to int before passing to the API"],"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"}