mlflow/mlflow · error · MlflowException

INVALID_PARAMETER_VALUE

INVALID_PARAMETER_VALUE

Error message

Invalid value {max_results} for parameter 'max_results' supplied. It must be a positive integer

What it means

FileStore.search_experiments validates max_results: it must be a positive int, and raises MlflowException with INVALID_PARAMETER_VALUE otherwise (a separate threshold check enforces the upper bound). This prevents nonsensical pagination sizes in the file-backed search implementation.

Source

Thrown at mlflow/store/tracking/file_store.py:363

            exp
            for exp in exp_list
            if not exp.endswith(FileStore.TRASH_FOLDER_NAME)
            and exp != ModelRegistryFileStore.MODELS_FOLDER_NAME
        ]

    def _get_deleted_experiments(self, full_path=False):
        return list_subdirs(self.trash_folder, full_path)

    def search_experiments(
        self,
        view_type=ViewType.ACTIVE_ONLY,
        max_results=SEARCH_MAX_RESULTS_DEFAULT,
        filter_string=None,
        order_by=None,
        page_token=None,
    ):
        if not isinstance(max_results, int) or max_results < 1:
            raise MlflowException(
                f"Invalid value {max_results} for parameter 'max_results' supplied. It must be "
                f"a positive integer",
                INVALID_PARAMETER_VALUE,
            )
        if max_results > SEARCH_MAX_RESULTS_THRESHOLD:
            raise MlflowException(
                f"Invalid value {max_results} for parameter 'max_results' supplied. It must be at "
                f"most {SEARCH_MAX_RESULTS_THRESHOLD}",
                INVALID_PARAMETER_VALUE,
            )

        self._check_root_dir()
        experiment_ids = []
        if view_type in (ViewType.ACTIVE_ONLY, ViewType.ALL):
            experiment_ids += self._get_active_experiments(full_path=False)
        if view_type in (ViewType.DELETED_ONLY, ViewType.ALL):
            experiment_ids += self._get_deleted_experiments(full_path=False)

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Pass a positive integer, e.g., max_results=int(config_value) with a >= 1 check.
  2. Clamp to the allowed range (1..SEARCH_MAX_RESULTS_THRESHOLD) before calling.
  3. Fix upstream config parsing to emit ints, not strings.

Example fix

// before
mlflow.search_experiments(max_results=argv.page_size)
// after
size = int(argv.page_size)
assert size >= 1
mlflow.search_experiments(max_results=size)
Defensive patterns

Strategy: validation

Validate before calling

def valid_max_results(v) -> int:
    n = int(v)
    if n < 1:
        raise ValueError("max_results must be a positive integer")
    return n

Type guard

def is_positive_int(v) -> bool:
    return isinstance(v, int) and not isinstance(v, bool) and v >= 1

Try / catch

from mlflow.exceptions import MlflowException
try:
    exps = mlflow.search_experiments(max_results=n)
except MlflowException as e:
    if e.error_code == "INVALID_PARAMETER_VALUE":
        exps = mlflow.search_experiments(max_results=100)

Prevention

When it happens

Trigger: Calling search_experiments with max_results=0, a negative number, a non-int (e.g., string from CLI args or float), or an int-like numpy type.

Common situations: Passing command-line/config strings without int() conversion; computing page size with arithmetic that yields 0; copying max_results from a config file as a string.

Related errors


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