{"record":{"id":"8e37dc8009ff07c9","repo":"mlflow/mlflow","slug":"artifact-path-cannot-be-specified-if-artifact-u","errorCode":null,"errorMessage":"`artifact_path` cannot be specified if `artifact_uri` is specified","messagePattern":"`artifact_path` cannot be specified if `artifact_uri` is specified","errorType":"validation","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/artifacts/__init__.py","lineNumber":136,"sourceCode":"        artifact_uri: URI pointing to the artifacts, such as\n            ``\"runs:/500cf58bee2b40a4a82861cc31a617b1/my_model.pkl\"``,\n            ``\"models:/my_model/Production\"``, or ``\"s3://my_bucket/my/file.txt\"``.\n            Exactly one of ``artifact_uri`` or ``run_id`` must be specified.\n        run_id: ID of the MLflow Run containing the artifacts. Exactly one of ``run_id`` or\n            ``artifact_uri`` must be specified.\n        artifact_path: (For use with ``run_id``) If specified, a path relative to the MLflow\n            Run's root directory containing the artifacts to list.\n        tracking_uri: The tracking URI to be used when list artifacts.\n\n    Returns:\n        List of artifacts as FileInfo listed directly under path.\n    \"\"\"\n    if (run_id, artifact_uri).count(None) != 1:\n        raise MlflowException.invalid_parameter_value(\n            message=\"Exactly one of `run_id` or `artifact_uri` must be specified\",\n        )\n    elif artifact_uri is not None and artifact_path is not None:\n        raise MlflowException.invalid_parameter_value(\n            message=\"`artifact_path` cannot be specified if `artifact_uri` is specified\",\n        )\n\n    if artifact_uri is not None:\n        root_uri, artifact_path = _get_root_uri_and_artifact_path(artifact_uri)\n        return get_artifact_repository(\n            artifact_uri=root_uri, tracking_uri=tracking_uri\n        ).list_artifacts(artifact_path)\n\n    # Use `runs:/<run_id>/<artifact_path>` to list both run and model (if exists) artifacts\n    if run_id and artifact_path:\n        return get_artifact_repository(\n            artifact_uri=f\"runs:/{run_id}\", tracking_uri=tracking_uri\n        ).list_artifacts(artifact_path)\n\n    store = _get_store(store_uri=tracking_uri)\n    artifact_uri = store.get_run(run_id).info.artifact_uri\n    artifact_repo = get_artifact_repository(","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/artifacts/__init__.py#L118-L154","documentation":"When listing via artifact_uri there is no run to resolve a sub-path against, so passing artifact_path alongside artifact_uri is rejected with INVALID_PARAMETER_VALUE.","triggerScenarios":"Calling list_artifacts(artifact_uri=\"s3://bucket/run/artifacts\", artifact_path=\"model\").","commonSituations":"Shared helper that always forwards artifact_path; converting run_id-based listing code to URI-based without dropping artifact_path.","solutions":["Drop artifact_path and embed the sub-path into artifact_uri","Use run_id + artifact_path instead if listing inside a run","Guard in wrappers: set artifact_path=None whenever artifact_uri is given"],"exampleFix":"// before\nlist_artifacts(artifact_uri=\"s3://bucket/run/artifacts\", artifact_path=\"model\")\n// after\nlist_artifacts(artifact_uri=\"s3://bucket/run/artifacts/model\")","handlingStrategy":"validation","validationCode":"if artifact_uri is not None:\n    assert artifact_path is None, \"embed sub-path in artifact_uri instead\"","typeGuard":null,"tryCatchPattern":"try:\n    infos = mlflow.artifacts.list_artifacts(artifact_uri=uri, artifact_path=sub)\nexcept MlflowException as e:\n    if \"artifact_path` cannot be specified\" in str(e):\n        infos = mlflow.artifacts.list_artifacts(artifact_uri=f\"{uri.rstrip('/')}/{sub}\")\n    else:\n        raise","preventionTips":["Treat artifact_uri as fully-resolved: include the sub-path in it","Use run_id + artifact_path when you need path-style listing","Centralize artifact listing in one validated helper"],"tags":["artifacts","invalid-parameter","mutually-exclusive-args"],"backgroundTag":"mutually-exclusive-parameters","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}