mlflow/mlflow · error · MlflowException

INVALID_PARAMETER_VALUE

INVALID_PARAMETER_VALUE

Error message

The target provided is not a valid uri or 'databricks'

What it means

set_deployments_target accepts only a valid deployment URI or the literal 'databricks'. _is_valid_target checks this; anything else (invalid URI or wrong literal) is rejected with INVALID_PARAMETER_VALUE.

Source

Thrown at mlflow/deployments/utils.py:63

            in the case of Databricks, the fully qualified url.

    Returns:
        The complete URL, either directly returned or formed and returned by joining the
        base URL and the endpoint path.

    """
    return endpoint if _is_valid_uri(endpoint) else append_to_uri_path(base_url, endpoint)


def set_deployments_target(target: str):
    """Sets the target deployment client for MLflow deployments

    Args:
        target: The full uri of a running MLflow AI Gateway or, if running on
            Databricks, "databricks".
    """
    if not _is_valid_target(target):
        raise MlflowException.invalid_parameter_value(
            "The target provided is not a valid uri or 'databricks'"
        )

    global _deployments_target
    _deployments_target = target


def get_deployments_target() -> str:
    """
    Returns the currently set MLflow deployments target iff set.
    If the deployments target has not been set by using ``set_deployments_target``, an
    ``MlflowException`` is raised.
    """
    if _deployments_target is not None:
        return _deployments_target
    elif uri := MLFLOW_DEPLOYMENTS_TARGET.get():
        return uri
    else:

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Pass a full URI with scheme, e.g. 'https://ai-gateway.example.com' or 'http://localhost:5000'
  2. Or pass the exact lowercase string 'databricks' when on Databricks
  3. Normalize/validate the target before calling (urlparse: require scheme, or target == 'databricks')

Example fix

// before
mlflow.deployments.set_deployments_target("localhost:5000")

// after
mlflow.deployments.set_deployments_target("http://localhost:5000")
Defensive patterns

Strategy: validation

Validate before calling

import urllib.parse
def check_target(target: str):
    assert target == "databricks" or urllib.parse.urlparse(target).scheme, \
        f"target must be a full uri or 'databricks', got {target!r}"

Type guard

def is_valid_deployments_target(target) -> bool:
    if not isinstance(target, str):
        return False
    return target == "databricks" or bool(urllib.parse.urlparse(target).scheme)

Try / catch

try:
    mlflow.deployments.set_deployments_target(target)
except MlflowException as e:
    if e.error_code == "INVALID_PARAMETER_VALUE":
        raise ValueError(f"Invalid deployments target: {target!r}") from e
    raise

Prevention

When it happens

Trigger: Calling mlflow.deployments.set_deployments_target(target) with a malformed URI (e.g. missing scheme like 'localhost:5000' without http, or an empty string) or a typo of 'databricks'.

Common situations: Typos like 'Databricks' (case-sensitive) or 'databrick'; passing 'localhost:5000' without a scheme; passing None or a config value that is empty.

Related errors


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