mlflow/mlflow · error · ValueError

Either 'name' or 'dataset_id' must be provided.

Error message

Either 'name' or 'dataset_id' must be provided.

What it means

_validate_non_databricks_get_params requires at least one identifier for get_dataset outside Databricks. Calling it with both name and dataset_id as None raises ValueError.

Source

Thrown at mlflow/genai/datasets/__init__.py:125

        raise ValueError(
            "Parameter 'name' is only supported in Databricks environments. "
            "Use 'dataset_id' parameter instead."
        )
    if dataset_id is None:
        raise ValueError(
            "Parameter 'dataset_id' is required. "
            "Use search_datasets() to find the dataset ID by name if needed."
        )


def _validate_non_databricks_get_params(
    name: str | None,
    dataset_id: str | None = None,
) -> None:
    if name is not None and dataset_id is not None:
        raise ValueError("Cannot specify both 'name' and 'dataset_id'. Use only one parameter.")
    if name is None and dataset_id is None:
        raise ValueError("Either 'name' or 'dataset_id' must be provided.")


def _get_dataset_by_name(name: str) -> EntityEvaluationDataset:
    """Get a dataset by name."""
    # Build filter string with appropriate quoting:
    # - Use double quotes if name has no double quotes (handles single quotes)
    # - Use single quotes if name has double quotes but no single quotes
    # - Use single quotes with SQL-style escaping ('') if name has both
    if '"' not in name:
        filter_string = f'name = "{name}"'
    elif "'" not in name:
        filter_string = f"name = '{name}'"
    else:
        escaped_name = name.replace("'", "''")
        filter_string = f"name = '{escaped_name}'"

    results = MlflowClient().search_datasets(
        filter_string=filter_string,

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Pass dataset_id="..." (or name="...") to get_dataset.
  2. Validate identifier presence at the call site before invoking.
  3. Check the config/lookup that should supply the identifier.

Example fix

// before
get_dataset()
// after
get_dataset(dataset_id="abc-123")
Defensive patterns

Strategy: validation

Validate before calling

assert name is not None or dataset_id is not None, "must provide name or dataset_id"

Type guard

def any_identifier(name: str | None, dataset_id: str | None) -> bool:
    return name is not None or dataset_id is not None

Try / catch

try:
    ds = get_dataset(**ident_kwargs)
except ValueError as e:
    if "Either 'name' or 'dataset_id'" in str(e):
        raise RuntimeError("no dataset identifier configured") from e
    raise

Prevention

When it happens

Trigger: get_dataset() or get_dataset(name=None, dataset_id=None) outside a Databricks environment.

Common situations: Variables resolved from config/CLI args that came through as None, or a call site that dropped its arguments during refactoring.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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