mlflow/mlflow · error · MlflowException

INVALID_PARAMETER_VALUE

INVALID_PARAMETER_VALUE

Error message

Invalid experiment ID '{experiment_id}'. Experiment ID must be a valid integer.

What it means

MLflow's SQLAlchemy tracking store requires experiment IDs to be integers. `_get_experiment` attempts `int(experiment_id)` and raises this INVALID_PARAMETER_VALUE error when the value is a non-numeric string, None, or otherwise unconvertible. It means the caller passed a malformed experiment identifier, not that the experiment is missing.

Source

Thrown at mlflow/store/tracking/sqlalchemy_store.py:753

        return sql_experiment.to_mlflow_entity(
            effective_trace_archival_retention=effective_trace_archival_retention
        )

    def _get_experiment(self, session, experiment_id, view_type, eager=False):
        """
        Args:
            eager: If ``True``, eagerly loads the experiments's tags. If ``False``, these tags
                are not eagerly loaded and will be loaded if/when their corresponding
                object properties are accessed from the resulting ``SqlExperiment`` object.
        """
        experiment_id = experiment_id or SqlAlchemyStore.DEFAULT_EXPERIMENT_ID
        stages = LifecycleStage.view_type_to_stages(view_type)
        query_options = self._get_eager_experiment_query_options() if eager else []

        try:
            experiment_id_int = int(experiment_id)
        except (ValueError, TypeError):
            raise MlflowException(
                f"Invalid experiment ID '{experiment_id}'. Experiment ID must be a valid integer.",
                INVALID_PARAMETER_VALUE,
            )

        experiment = (
            self
            ._get_query(session, SqlExperiment)
            .options(*query_options)
            .filter(
                SqlExperiment.experiment_id == experiment_id_int,
                SqlExperiment.lifecycle_stage.in_(stages),
            )
            .one_or_none()
        )

        if experiment is None:
            raise MlflowException(
                f"No Experiment with id={experiment_id_int} exists", RESOURCE_DOES_NOT_EXIST

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Inspect the value passed as experiment_id and print/repr it right before the call to see what is actually being passed
  2. If you have an experiment name, resolve it to an ID first with mlflow.get_experiment_by_name(name).experiment_id
  3. Validate the ID is numeric before calling: str(id).isdigit() or a try/int() cast
  4. Check upstream code for accidentally passing a name, path, run ID, or None instead of the experiment ID
  5. When reading IDs from env/config/CLI, strip whitespace and fail fast with a clear message if not numeric

Example fix

// before
exp = mlflow.get_experiment("my-experiment")  # name, not an ID

// after
exp = mlflow.get_experiment_by_name("my-experiment")
# or if you have an ID:
exp = mlflow.get_experiment("123")
Defensive patterns

Strategy: validation

Validate before calling

def validate_experiment_id(experiment_id):
    if experiment_id is None:
        raise ValueError("experiment_id is required")
    try:
        return int(experiment_id)
    except (ValueError, TypeError):
        raise ValueError(f"experiment_id must be numeric, got {experiment_id!r}")

exp = mlflow.get_experiment(str(validate_experiment_id(raw_id)))

Type guard

def is_valid_experiment_id(value) -> bool:
    try:
        int(value)
        return True
    except (ValueError, TypeError):
        return False

Try / catch

from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
try:
    exp = mlflow.get_experiment(exp_id)
except MlflowException as e:
    if e.get_http_status_code() == 400 and e.error_code == INVALID_PARAMETER_VALUE:
        exp = mlflow.get_experiment_by_name(exp_id)  # maybe a name was passed
    else:
        raise

Prevention

When it happens

Trigger: Calling get_experiment, delete_experiment, restore_experiment, rename_experiment, or set_experiment_tag with an experiment_id like 'abc', '', 'None', a float string, or None instead of a numeric ID string/int.

Common situations: Parsing experiment IDs from URLs, config files, or CLI args where the value was never validated; accidentally passing an experiment *name* where an ID is expected; storing IDs as strings and passing empty/garbage values after a failed lookup; passing a Run or Model object instead of its experiment_id field.

Related errors


AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29). Data as JSON: /api/errors/62bdfb5cce8222dc. Report an issue: GitHub.