{"record":{"id":"e452367581da29f2","repo":"mlflow/mlflow","slug":"invalid-lifecycle-stage-lifecycle-stage","errorCode":null,"errorMessage":"Invalid lifecycle stage '{lifecycle_stage}'","messagePattern":"Invalid lifecycle stage '(.+?)'","errorType":"exception","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/entities/lifecycle_stage.py","lineNumber":26,"sourceCode":"    _VALID_STAGES = {ACTIVE, DELETED}\n\n    @classmethod\n    def view_type_to_stages(cls, view_type: int = ViewType.ALL) -> list[str]:\n        stages = []\n        if view_type in (ViewType.ACTIVE_ONLY, ViewType.ALL):\n            stages.append(cls.ACTIVE)\n        if view_type in (ViewType.DELETED_ONLY, ViewType.ALL):\n            stages.append(cls.DELETED)\n        return stages\n\n    @classmethod\n    def is_valid(cls, lifecycle_stage: str) -> bool:\n        return lifecycle_stage in cls._VALID_STAGES\n\n    @classmethod\n    def matches_view_type(cls, view_type: int, lifecycle_stage: str) -> bool:\n        if not cls.is_valid(lifecycle_stage):\n            raise MlflowException(f\"Invalid lifecycle stage '{lifecycle_stage}'\")\n\n        if view_type == ViewType.ALL:\n            return True\n        elif view_type == ViewType.ACTIVE_ONLY:\n            return lifecycle_stage == LifecycleStage.ACTIVE\n        elif view_type == ViewType.DELETED_ONLY:\n            return lifecycle_stage == LifecycleStage.DELETED\n        else:\n            raise MlflowException(f\"Invalid view type '{view_type}'\")\n","sourceCodeStart":8,"sourceCodeEnd":36,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/entities/lifecycle_stage.py#L8-L36","documentation":"LifecycleStage.matches_view_type(view_type, lifecycle_stage) first validates the lifecycle_stage string against the known stages (active/deleted). This MlflowException means an unrecognized lifecycle_stage string was passed. Callers such as _list_run_infos invoke it when filtering run listings by view type.","triggerScenarios":"Passing a lifecycle_stage string that is not exactly 'active' or 'deleted' (e.g. 'Active', 'live', '', 'archived') into search_runs with run_view_type filtering paths, or any code calling LifecycleStage.matches_view_type / _list_run_infos with a corrupt or custom stage value stored in run metadata.","commonSituations":"Case-sensitivity mistakes ('Active' vs 'active'); a corrupted run record in the tracking store with a bad stage value; third-party tooling writing custom lifecycle stage strings directly to the backend DB.","solutions":["Use the LifecycleStage enum constants (LifecycleStage.ACTIVE / LifecycleStage.DELETED) instead of raw strings.","Call LifecycleStage.is_valid(stage) before passing the value.","Fix any corrupted lifecycle_stage values in the tracking store database (runs table).","Lowercase/normalize user-supplied stage strings before use."],"exampleFix":"// before\nclient.search_runs(experiment_ids, run_view_type=ViewType.ACTIVE_ONLY, filter_string=\"\")  # stage read from DB as 'Active'\n// after\nfrom mlflow.entities import LifecycleStage\nstage = (raw_stage or \"\").lower()\nassert LifecycleStage.is_valid(stage), f\"bad stage: {stage}\"","handlingStrategy":"validation","validationCode":"from mlflow.entities import LifecycleStage\nif not LifecycleStage.is_valid(stage):\n    raise ValueError(f\"invalid lifecycle stage: {stage!r}\")","typeGuard":"def is_valid_stage(s: object) -> bool:\n    return isinstance(s, str) and LifecycleStage.is_valid(s)","tryCatchPattern":"try:\n    runs = client.search_runs(exp_ids, run_view_type=vt)\nexcept MlflowException as e:\n    if \"Invalid lifecycle stage\" in str(e):\n        fix_corrupted_run_records()\n    raise","preventionTips":["Always use LifecycleStage.ACTIVE / DELETED constants, never raw strings","Normalize case (.lower()) on any externally sourced stage value","Avoid writing custom stage values directly to the tracking store DB"],"tags":["python","validation","lifecycle-stage","runs"],"backgroundTag":"invalid-enum-value","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}