oraios/serena · error · ValueError
min_severity must be one of 1, 2, 3, 4, got {min_severity}
Error message
min_severity must be one of 1, 2, 3, 4, got {min_severity} What it means
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.
Source
Thrown at src/solidlsp/ls.py:822
diagnostics = [d for d in diagnostics if cls._diagnostic_matches_min_severity(d, min_severity)]
return diagnostics
def _validate_text_document_diagnostics_request(
self,
relative_file_path: str,
start_line: int,
end_line: int,
min_severity: int,
) -> str:
if not self.server_started:
log.error("request_text_document_diagnostics called before Language Server started")
raise SolidLSPException("Language Server not started")
if start_line < 0:
raise ValueError(f"start_line must be non-negative, got {start_line}")
if end_line != -1 and end_line < start_line:
raise ValueError(f"end_line must be -1 or >= start_line, got {end_line} < {start_line}")
if min_severity not in {1, 2, 3, 4}:
raise ValueError(f"min_severity must be one of 1, 2, 3, 4, got {min_severity}")
return pathlib.Path(str(PurePath(self.repository_root_path, relative_file_path))).as_uri()
def get_published_diagnostics_generation(self, relative_file_path: str) -> int:
"""
Get the generation number for the latest published diagnostics of a file.
:param relative_file_path: The relative path of the file.
:return: the generation number, or ``-1`` if none were published yet.
"""
uri = pathlib.Path(str(PurePath(self.repository_root_path, relative_file_path))).as_uri()
return self._get_published_diagnostics_generation(uri)
def get_cached_published_text_document_diagnostics(
self,
relative_file_path: str,
start_line: int = 0,
end_line: int = -1,
min_severity: int = 4,View on GitHub (pinned to 7fcbca7e62)
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
Example fix
// before
ls.request_text_document_diagnostics("src/a.py", 0, -1, 0) # 0 invalid
// after
ls.request_text_document_diagnostics("src/a.py", 0, -1, 4) # 4 = include hints and above Defensive patterns
Strategy: validation
Validate before calling
VALID_SEVERITIES = {1, 2, 3, 4}
if min_severity not in VALID_SEVERITIES:
raise ValueError(f"min_severity must be one of {sorted(VALID_SEVERITIES)}, got {min_severity}") Prevention
- 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
When it happens
Trigger: 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.
Common situations: Using 0 as 'all severities' instead of 4; passing an enum object instead of its int value; off-by-one assumptions about severity ordering.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- start_line must be non-negative, got {start_line}
- end_line must be -1 or >= start_line, got {end_line} < {star
- Language Server not started
- Unknown language '{lang}'. Supported: {all_langs}
- Cannot edit external file: {relative_path}
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/416fe35ffbce3d44.
Report an issue: GitHub.