{"record":{"id":"b6c82c251c13472c","repo":"mlflow/mlflow","slug":"invalid-version-number-version","errorCode":null,"errorMessage":"Invalid version number: {version}","messagePattern":"Invalid version number: (.+?)","errorType":"validation","errorClass":"MlflowException","httpStatus":400,"severity":"error","filePath":"mlflow/store/model_registry/abstract_store.py","lineNumber":910,"sourceCode":"        except Exception:\n            return None\n\n    def delete_prompt_version(self, name: str, version: str | int) -> None:\n        \"\"\"\n        Delete a specific prompt version.\n\n        Default implementation: deletes the underlying ModelVersion.\n        Other store implementations may override this method.\n\n        Args:\n            name: Name of the prompt.\n            version: Version number to delete.\n        \"\"\"\n        # Convert version to int if needed\n        try:\n            version_int = int(version)\n        except (ValueError, TypeError):\n            raise MlflowException(f\"Invalid version number: {version}\")\n        return self.delete_model_version(name, version_int)\n\n    def get_prompt_version_by_alias(self, name: str, alias: str) -> PromptVersion | None:\n        \"\"\"\n        Get a prompt version by alias.\n\n        Default implementation: uses get_model_version_by_alias and converts to PromptVersion.\n\n        Args:\n            name: Name of the prompt.\n            alias: Alias name.\n\n        Returns:\n            A PromptVersion object, or None if not found.\n        \"\"\"\n        return self.get_prompt_version(name, alias)\n\n    def set_prompt_alias(self, name: str, alias: str, version: str | int) -> None:","sourceCodeStart":892,"sourceCodeEnd":928,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/store/model_registry/abstract_store.py#L892-L928","documentation":"delete_prompt_version() coerces the prompt version to an int before delegating to delete_model_version(). If int(version) raises ValueError or TypeError, MLflow throws MlflowException 'Invalid version number: {version}'. This guards the registry backend against malformed version identifiers.","triggerScenarios":"Calling client.delete_prompt_version(name, version) with a non-numeric version such as 'v1', '1.0', None, or an object whose __int__ conversion fails.","commonSituations":"Passing a version string parsed from JSON/config that includes a prefix (e.g. 'version-3'), passing a PromptVersion object instead of its .version field, or passing None after a failed lookup.","solutions":["Pass the numeric version string, e.g. '1' instead of 'v1'","Strip non-numeric prefixes from the version string before calling","Access the .version attribute of a PromptVersion entity rather than passing the entity itself","Validate the version is numeric before calling"],"exampleFix":"// before\nclient.delete_prompt_version(\"my_prompt\", \"v3\")\n// after\nclient.delete_prompt_version(\"my_prompt\", \"3\")  # or version_obj.version","handlingStrategy":"validation","validationCode":"def is_valid_prompt_version(v):\n    try:\n        int(v)\n        return True\n    except (ValueError, TypeError):\n        return False\nif not is_valid_prompt_version(version):\n    raise ValueError(f\"Numeric version required, got: {version!r}\")","typeGuard":"def is_int_str(v) -> bool:\n    return isinstance(v, int) or (isinstance(v, str) and v.isdigit())","tryCatchPattern":"from mlflow.exceptions import MlflowException\ntry:\n    client.delete_prompt_version(name, version)\nexcept MlflowException as e:\n    if \"Invalid version number\" in str(e):\n        logger.error(f\"Bad version {version!r} for {name}: {e}\")","preventionTips":["Always pass the numeric .version field of a PromptVersion entity","Never pass alias strings where numeric versions are required","Sanitize version strings parsed from external sources before calling","Store prompt versions as ints/numeric strings in your config"],"tags":["mlflow","model-registry","validation","prompt-versions"],"backgroundTag":"invalid-version-number","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}