{"record":{"id":"bb2fbbaa2e01e68f","repo":"mlflow/mlflow","slug":"invalid-parameter-value-bb2fbb","errorCode":"INVALID_PARAMETER_VALUE","errorMessage":"Both dataset_name and dataset_digest must be provided if one is provided","messagePattern":"Both dataset_name and dataset_digest must be provided if one is provided","errorType":"validation","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/entities/metric.py","lineNumber":25,"sourceCode":"\nclass Metric(_MlflowObject):\n    \"\"\"\n    Metric object.\n    \"\"\"\n\n    def __init__(\n        self,\n        key,\n        value,\n        timestamp,\n        step,\n        model_id: str | None = None,\n        dataset_name: str | None = None,\n        dataset_digest: str | None = None,\n        run_id: str | None = None,\n    ):\n        if (dataset_name, dataset_digest).count(None) == 1:\n            raise MlflowException(\n                \"Both dataset_name and dataset_digest must be provided if one is provided\",\n                INVALID_PARAMETER_VALUE,\n            )\n\n        self._key = key\n        self._value = value\n        self._timestamp = timestamp\n        self._step = step\n        self._model_id = model_id\n        self._dataset_name = dataset_name\n        self._dataset_digest = dataset_digest\n        self._run_id = run_id\n\n    @property\n    def key(self):\n        \"\"\"String key corresponding to the metric name.\"\"\"\n        return self._key\n","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/entities/metric.py#L7-L43","documentation":"Metric requires dataset_name and dataset_digest to be supplied together: if exactly one of the two is provided, __init__ raises this error. The pairing is required so dataset-linked metrics can be uniquely identified.","triggerScenarios":"mlflow.log_metric(..., dataset_name=\"x\") without dataset_digest, or vice versa; constructing Metric(key, value, timestamp, step, dataset_name=\"x\") directly; one of the two dropped by a wrapper or defaults layer.","commonSituations":"Copy-pasted logging code where one argument was deleted; calling log_metric with keyword args supported in a newer MLflow but one forgotten; generating metrics in a loop where only the name is templated.","solutions":["Provide both dataset_name and dataset_digest together in the call","If the metric is not dataset-linked, omit both arguments entirely","Update calling code/wrappers so both values are sourced from the same dataset metadata"],"exampleFix":"// before\nmlflow.log_metric(\"rmse\", 0.2, dataset_name=\"train_set\")\n// after\nmlflow.log_metric(\"rmse\", 0.2, dataset_name=\"train_set\", dataset_digest=\"abc123\")","handlingStrategy":"validation","validationCode":"if (dataset_name is None) != (dataset_digest is None):\n    raise ValueError(\"dataset_name and dataset_digest must be provided together\")","typeGuard":null,"tryCatchPattern":"try:\n    mlflow.log_metric(\"rmse\", 0.2, dataset_name=ds_name, dataset_digest=ds_digest)\nexcept MlflowException as e:\n    logger.error(\"Metric logging failed: %s\", e)","preventionTips":["Always pass dataset_name and dataset_digest from the same source object","Omit both when the metric is not dataset-linked","Add a unit test around logging wrappers that forward these kwargs"],"tags":["mlflow","metrics","validation","parameter-pairing"],"backgroundTag":"missing-required-field","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}