{"record":{"id":"45f90acf3224c597","repo":"mlflow/mlflow","slug":"the-artifact-file-parameter-cannot-be-used-in-co","errorCode":null,"errorMessage":"The `artifact_file` parameter cannot be used in conjunction with `key`, `step`, or `timestamp` parameters. Please ensure that `artifact_file` is specified alone, without any of these conflicting parameters.","messagePattern":"The `artifact_file` parameter cannot be used in conjunction with `key`, `step`, or `timestamp` parameters\\. Please ensure that `artifact_file` is specified alone, without any of these conflicting parameters\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"mlflow/tracking/client.py","lineNumber":3238,"sourceCode":"                client = mlflow.MlflowClient()\n                client.log_image(run.info.run_id, image, \"image.png\")\n\n        .. code-block:: python\n            :caption: Legacy artifact file image logging pillow example\n\n            import mlflow\n            from PIL import Image\n\n            image = Image.new(\"RGB\", (100, 100))\n            with mlflow.start_run() as run:\n                client = mlflow.MlflowClient()\n                client.log_image(run.info.run_id, image, \"image.png\")\n        \"\"\"\n        synchronous = (\n            synchronous if synchronous is not None else not MLFLOW_ENABLE_ASYNC_LOGGING.get()\n        )\n        if artifact_file is not None and any(arg is not None for arg in [key, step, timestamp]):\n            raise TypeError(\n                \"The `artifact_file` parameter cannot be used in conjunction with `key`, \"\n                \"`step`, or `timestamp` parameters. Please ensure that `artifact_file` is \"\n                \"specified alone, without any of these conflicting parameters.\"\n            )\n        elif artifact_file is None and key is None:\n            raise TypeError(\n                \"Invalid arguments: Please specify exactly one of `artifact_file` or `key`. Use \"\n                \"`key` to log dynamic image charts or `artifact_file` for saving static images. \"\n            )\n\n        import numpy as np\n\n        # Convert image type to PIL if its a numpy array\n        if isinstance(image, np.ndarray):\n            image = convert_to_pil_image(image)\n        elif isinstance(image, Image):\n            image = image.to_pil()\n        else:","sourceCodeStart":3220,"sourceCodeEnd":3256,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/tracking/client.py#L3220-L3256","documentation":"MLflow's MlflowClient.log_image() supports two mutually exclusive ways to log an image: a static file via `artifact_file`, or a dynamic chart via `key` (with optional `step`/`timestamp`). Passing `artifact_file` together with any of `key`, `step`, or `timestamp` is ambiguous, so the method raises a TypeError before doing any work.","triggerScenarios":"Calling client.log_image(run_id, image, artifact_file='image.png') while also passing key, step, or timestamp (any non-None value among them). The check is `artifact_file is not None and any(arg is not None for arg in [key, step, timestamp])`.","commonSituations":"Migrating code from the key-based logging API to file-based logging and leaving a leftover step=0 or timestamp argument; copy-pasting examples of both styles into one call; building a wrapper that forwards all kwargs unconditionally.","solutions":["Remove `key`, `step`, and `timestamp` arguments when logging a static image with `artifact_file`.","If you need step/timestamp tracking, switch to the dynamic-chart style: pass `key` instead of `artifact_file`.","If wrapping log_image, conditionally forward only the relevant parameter group based on which mode is intended."],"exampleFix":"// before\nclient.log_image(run_id, img, artifact_file=\"image.png\", step=3)\n// after\nclient.log_image(run_id, img, artifact_file=\"image.png\")","handlingStrategy":"validation","validationCode":"if artifact_file is not None and any(a is not None for a in (key, step, timestamp)):\n    raise ValueError(\"Use either artifact_file OR (key, step, timestamp), not both\")","typeGuard":null,"tryCatchPattern":"try:\n    client.log_image(run_id, img, artifact_file=\"image.png\", step=step)\nexcept TypeError as e:\n    if \"artifact_file\" in str(e):\n        client.log_image(run_id, img, artifact_file=\"image.png\")\n    else:\n        raise","preventionTips":["Pick one logging mode per call site and document it","In wrappers, forward only the parameter group that is populated","Keep step/timestamp usage only with the key-based API"],"tags":["python","api-misuse","parameter-conflict","mlflow"],"backgroundTag":"conflicting-parameters","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}