mlflow/mlflow · error · MlflowException

RESOURCE_DOES_NOT_EXIST

RESOURCE_DOES_NOT_EXIST

Error message

Model definitions not found: {', '.join(missing)}

What it means

Every model configuration supplied to create_gateway_endpoint must reference an existing gateway model definition. MLflow looks up all referenced IDs in one query and raises RESOURCE_DOES_NOT_EXIST listing the IDs that were not found. The endpoint is not created.

Source

Thrown at mlflow/store/tracking/gateway/sqlalchemy_mixin.py:667

        if not model_configs:
            raise MlflowException(
                "Endpoint must have at least one model configuration",
                error_code=INVALID_PARAMETER_VALUE,
            )

        with self.ManagedSessionMaker(read_only=False) as session:
            # Validate all model definitions exist
            all_model_def_ids = {config.model_definition_id for config in model_configs}

            existing_model_defs = (
                self
                ._get_query(session, SqlGatewayModelDefinition)
                .filter(SqlGatewayModelDefinition.model_definition_id.in_(all_model_def_ids))
                .all()
            )
            existing_ids = {m.model_definition_id for m in existing_model_defs}
            if missing := all_model_def_ids - existing_ids:
                raise MlflowException(
                    f"Model definitions not found: {', '.join(missing)}",
                    error_code=RESOURCE_DOES_NOT_EXIST,
                )

            endpoint_id = f"e-{uuid.uuid4().hex}"
            current_time = get_current_time_millis()

            # Auto-create experiment if usage_tracking is enabled and no experiment_id provided
            if usage_tracking and experiment_id is None:
                experiment_id = self._get_or_create_experiment_id(
                    f"gateway/{name}",
                    tags=[
                        ExperimentTag(MLFLOW_EXPERIMENT_SOURCE_TYPE, "GATEWAY"),
                        ExperimentTag(MLFLOW_EXPERIMENT_SOURCE_ID, endpoint_id),
                        ExperimentTag(MLFLOW_EXPERIMENT_IS_GATEWAY, "true"),
                    ],
                )

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Correct the model_definition_id values, verifying each against search_gateway_model_definitions.
  2. Create the missing model definitions before creating the endpoint.
  3. Regenerate endpoint configs from the current backend rather than reusing stale IDs.
  4. Catch RESOURCE_DOES_NOT_EXIST and parse the message to identify which IDs are missing.

Example fix

// before
client.create_gateway_endpoint(name="chat", model_configs=[{"model_definition_id": "d-deleted"}])
// after
known = {d.model_definition_id for d in client.search_gateway_model_definitions()}
assert all(c["model_definition_id"] in known for c in model_configs), "unknown model_definition_id"
client.create_gateway_endpoint(name="chat", model_configs=model_configs)
Defensive patterns

Strategy: validation

Validate before calling

known = {d.model_definition_id for d in client.search_gateway_model_definitions()}
missing = [c["model_definition_id"] for c in model_configs if c["model_definition_id"] not in known]
if missing:
    raise ValueError(f"unknown model_definition_ids: {missing}")

Type guard

null

Try / catch

try:
    client.create_gateway_endpoint(...)
except MlflowException as e:
    if e.error_code == "RESOURCE_DOES_NOT_EXIST":
        raise RuntimeError(f"Create missing definitions first: {e}") from e
    raise

Prevention

When it happens

Trigger: Calling create_gateway_endpoint with a model_configs entry whose model_definition_id does not exist (deleted, wrong environment/database, or a typo).

Common situations: Reusing IDs exported from another MLflow backend or workspace; a definition deleted after configs were generated; hardcoded IDs in IaC templates; case/whitespace mistakes in IDs.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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