{"record":{"id":"bb28a3c38af16645","repo":"mlflow/mlflow","slug":"either-name-or-dataset-id-must-be-provided","errorCode":null,"errorMessage":"Either 'name' or 'dataset_id' must be provided.","messagePattern":"Either 'name' or 'dataset_id' must be provided\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mlflow/genai/datasets/__init__.py","lineNumber":125,"sourceCode":"        raise ValueError(\n            \"Parameter 'name' is only supported in Databricks environments. \"\n            \"Use 'dataset_id' parameter instead.\"\n        )\n    if dataset_id is None:\n        raise ValueError(\n            \"Parameter 'dataset_id' is required. \"\n            \"Use search_datasets() to find the dataset ID by name if needed.\"\n        )\n\n\ndef _validate_non_databricks_get_params(\n    name: str | None,\n    dataset_id: str | None = None,\n) -> None:\n    if name is not None and dataset_id is not None:\n        raise ValueError(\"Cannot specify both 'name' and 'dataset_id'. Use only one parameter.\")\n    if name is None and dataset_id is None:\n        raise ValueError(\"Either 'name' or 'dataset_id' must be provided.\")\n\n\ndef _get_dataset_by_name(name: str) -> EntityEvaluationDataset:\n    \"\"\"Get a dataset by name.\"\"\"\n    # Build filter string with appropriate quoting:\n    # - Use double quotes if name has no double quotes (handles single quotes)\n    # - Use single quotes if name has double quotes but no single quotes\n    # - Use single quotes with SQL-style escaping ('') if name has both\n    if '\"' not in name:\n        filter_string = f'name = \"{name}\"'\n    elif \"'\" not in name:\n        filter_string = f\"name = '{name}'\"\n    else:\n        escaped_name = name.replace(\"'\", \"''\")\n        filter_string = f\"name = '{escaped_name}'\"\n\n    results = MlflowClient().search_datasets(\n        filter_string=filter_string,","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/genai/datasets/__init__.py#L107-L143","documentation":"_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.","triggerScenarios":"get_dataset() or get_dataset(name=None, dataset_id=None) outside a Databricks environment.","commonSituations":"Variables resolved from config/CLI args that came through as None, or a call site that dropped its arguments during refactoring.","solutions":["Pass dataset_id=\"...\" (or name=\"...\") to get_dataset.","Validate identifier presence at the call site before invoking.","Check the config/lookup that should supply the identifier."],"exampleFix":"// before\nget_dataset()\n// after\nget_dataset(dataset_id=\"abc-123\")","handlingStrategy":"validation","validationCode":"assert name is not None or dataset_id is not None, \"must provide name or dataset_id\"","typeGuard":"def any_identifier(name: str | None, dataset_id: str | None) -> bool:\n    return name is not None or dataset_id is not None","tryCatchPattern":"try:\n    ds = get_dataset(**ident_kwargs)\nexcept ValueError as e:\n    if \"Either 'name' or 'dataset_id'\" in str(e):\n        raise RuntimeError(\"no dataset identifier configured\") from e\n    raise","preventionTips":["Fail fast when config resolution yields None identifiers.","Log which identifier source (env var/config key) was expected.","Require identifier arguments positionally or with no defaults in internal wrappers."],"tags":["missing-parameter","genai-datasets","validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}