{"record":{"id":"ee7e36f6868594c5","repo":"mlflow/mlflow","slug":"invalid-artifact-path-artifact-path-bad-pat","errorCode":null,"errorMessage":"Invalid artifact path: '{artifact_path}'. {bad_path_message(artifact_path)}","messagePattern":"Invalid artifact path: '(.+?)'\\. (.+?)","errorType":"exception","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/store/artifact/artifact_repo.py","lineNumber":814,"sourceCode":"        chunks: AsyncIterable[bytes],\n        artifact_file_name: str,\n        artifact_path: str | None = None,\n    ) -> None:\n        \"\"\"\n        Log artifact contents from an async chunk stream.\n\n        Args:\n            chunks: Async iterable yielding binary chunks containing the artifact contents.\n            artifact_file_name: Artifact filename to log. Any directory components are\n                ignored; use ``artifact_path`` to specify the destination directory.\n            artifact_path: Directory within the run's artifact directory in which to log\n                the artifact.\n        \"\"\"\n\n\ndef verify_artifact_path(artifact_path):\n    if artifact_path and path_not_unique(artifact_path):\n        raise MlflowException(\n            f\"Invalid artifact path: '{artifact_path}'. {bad_path_message(artifact_path)}\"\n        )\n\n\n# Attachment IDs are auto-generated as UUID4 by Attachment.__init__.\n# Strict UUID validation doubles as path traversal prevention.\ndef _validate_attachment_path(path: str) -> None:\n    try:\n        parsed = uuid.UUID(path)\n        if str(parsed) != path:\n            raise ValueError(\"Non-canonical UUID format\")\n    except (ValueError, AttributeError, TypeError):\n        # error_code is INVALID_PARAMETER_VALUE but this is an attribute/type validation failure\n        raise MlflowException(\n            f\"Invalid attachment path: '{path}'. Attachment path must be a valid UUID.\",\n            error_code=INVALID_PARAMETER_VALUE,\n            error_class=\"ATTRIBUTE_NOT_FOUND\",\n        )","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/store/artifact/artifact_repo.py#L796-L832","documentation":"verify_artifact_path rejects artifact paths that are not unique/safe (path_not_unique check, e.g. paths containing traversal or non-unique segments). It raises a generic MlflowException with a message describing why the path is invalid. Called before log_artifact and _get_or_create_artifact_dir.","triggerScenarios":"Calling log_artifact / log_artifacts with an artifact_path such as '../escape', paths with repeated redundant segments, or other forms flagged by path_not_unique; also invoked internally when creating the artifact dir.","commonSituations":"Building artifact paths from untrusted or unsanitized user input; joining paths with '..' segments; double slashes or ambiguous relative segments in experiment/run artifact subpaths.","solutions":["Sanitize the artifact_path: remove '..' and normalize with os.path.normpath / PurePosixPath","Use flat, single-level, alphanumeric artifact paths (e.g. 'models/checkpoint-1')","Read the bad_path_message portion of the error for the exact rule violated"],"exampleFix":"// before\nclient.log_artifact(run_id, \"model.pkl\", artifact_path=\"../../etc/evil\")  # MlflowException\n// after\nartifact_path = \"models/checkpoint-1\"\nassert artifact_path == os.path.normpath(artifact_path)\nclient.log_artifact(run_id, \"model.pkl\", artifact_path=artifact_path)","handlingStrategy":"validation","validationCode":"from mlflow.utils.validation import path_not_unique\ndef safe_artifact_path(p):\n    if p and path_not_unique(p):\n        raise ValueError(p)\n    return p","typeGuard":null,"tryCatchPattern":"try:\n    client.log_artifact(run_id, local, artifact_path=p)\nexcept MlflowException as e:\n    if 'Invalid artifact path' in str(e):\n        p = os.path.normpath(p).strip('/')\n        client.log_artifact(run_id, local, artifact_path=p)","preventionTips":["Sanitize artifact paths built from user input","Normalize with PurePosixPath and reject '..' segments","Use flat alphanumeric artifact subpaths"],"tags":["artifact","path-validation","security","path-traversal"],"backgroundTag":"invalid-path","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}