{"record":{"id":"56f858c99b5d8774","repo":"oraios/serena","slug":"invalid-line-ending-value-r-valid-values-are","errorCode":null,"errorMessage":"Invalid line_ending: {value!r}. Valid values are: {valid}","messagePattern":"Invalid line_ending: (.+?)\\. Valid values are: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/serena/config/serena_config.py","lineNumber":272,"sourceCode":"    def newline_str(self) -> str | None:\n        \"\"\"The newline parameter value for :func:`open` and :meth:`Path.write_text`.\n\n        Returns ``None`` for native mode (platform default).\n        \"\"\"\n        if self is LineEnding.LF:\n            return \"\\n\"\n        elif self is LineEnding.CRLF:\n            return \"\\r\\n\"\n        return None\n\n    @classmethod\n    def from_str(cls, value: str) -> \"LineEnding\":\n        \"\"\"Parse a string value into a :class:`LineEnding`.\"\"\"\n        try:\n            return cls(value.lower())\n        except ValueError as e:\n            valid = [le.value for le in cls]\n            raise ValueError(f\"Invalid line_ending: {value!r}. Valid values are: {valid}\") from e\n\n\n@dataclass\nclass SharedConfig(ToolInclusionDefinition, ToStringMixin):\n    \"\"\"Shared between SerenaConfig and ProjectConfig, the latter used to override values in the form\n    (same as in ModeSelectionDefinition).\n    The defaults here shall be none and should be set to the global default values in SerenaConfig.\n    \"\"\"\n\n    symbol_info_budget: float | None = None\n    language_backend: LanguageBackend | None = None\n    line_ending: LineEnding | None = None\n    read_only_memory_patterns: list[str] = field(default_factory=list)\n    ignored_memory_patterns: list[str] = field(default_factory=list)\n    ls_specific_settings: dict = field(default_factory=dict)\n    \"\"\"Advanced configuration option allowing to configure language server implementation specific options, see SolidLSPSettings for more info.\"\"\"\n\n","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/config/serena_config.py#L254-L290","documentation":"LineEnding.from_str() converts a configured string into the LineEnding enum using cls(value.lower()). This ValueError is raised when the value is not one of the enum's accepted strings (e.g. 'lf', 'crlf', 'auto' style values), with the original parse error chained as __cause__.","triggerScenarios":"Setting line_ending to an unrecognized string in serena_config.yml or a project config, parsed via _from_dict/from_config_file; also calling LineEnding.from_str() directly with a bad value.","commonSituations":"Typos like 'LF\\r', 'windows', 'unix', or '\\r\\n' (raw escape characters) instead of the enum's named values; hand-editing YAML without knowing the accepted vocabulary.","solutions":["Set line_ending to one of the valid values listed in the error message (the enum's .value list).","Avoid using raw escape sequences like '\\r\\n'; use the named enum value instead.","Trim whitespace/quotes around the value in YAML.","Check the LineEnding enum definition in src/serena/config/serena_config.py for the canonical list."],"exampleFix":"# before (serena_config.yml)\nline_ending: '\\r\\n'\n# after\nline_ending: crlf","handlingStrategy":"validation","validationCode":"from serena.config.serena_config import LineEnding\n\nVALID_ENDINGS = [le.value for le in LineEnding]\n\ndef validate_line_ending(value: str) -> None:\n    if value.strip().lower() not in [v.lower() for v in VALID_ENDINGS]:\n        raise ValueError(f\"line_ending must be one of {VALID_ENDINGS}, got {value!r}\")","typeGuard":"def is_valid_line_ending(value: str) -> bool:\n    try:\n        LineEnding(value.lower())\n        return True\n    except ValueError:\n        return False","tryCatchPattern":"try:\n    line_ending = LineEnding.from_str(cfg.get(\"line_ending\", \"auto\"))\nexcept ValueError as e:\n    log.warning(\"%s; using default\", e)\n    line_ending = LineEnding.AUTO","preventionTips":["Use the named values from the error message, not raw escape sequences like '\\r\\n'.","Copy the line_ending key from a shipped example config instead of inventing values.","Normalize/strip user-supplied values before passing to from_str().","Keep enum usage centralized so valid values are discoverable from the enum itself."],"tags":["python","configuration","enum","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}