{"record":{"id":"ae6776b6a6eee604","repo":"mlflow/mlflow","slug":"invalid-parameter-value-ae6776","errorCode":"INVALID_PARAMETER_VALUE","errorMessage":"Failed to copy the specified code path '{code_path}' into the model artifacts. It appears that your code path includes file(s) that cannot be copied{example}. Please specify a code path that does not include such files and try again.","messagePattern":"Failed to copy the specified code path '(.+?)' into the model artifacts\\. It appears that your code path includes file\\(s\\) that cannot be copied(.+?)\\. Please specify a code path that does not include such files and try again\\.","errorType":"error_code","errorClass":"MlflowException","httpStatus":400,"severity":"error","filePath":"mlflow/utils/model_utils.py","lineNumber":202,"sourceCode":"    can later be used to log custom code as an artifact.\n\n    Args:\n        code_paths: A list of files or directories containing code that should be logged\n            as artifacts.\n        path: The local model path.\n        default_subpath: The default directory name used to store code artifacts.\n    \"\"\"\n    _validate_code_paths(code_paths)\n    if code_paths is not None:\n        code_dir_subpath = default_subpath\n        for code_path in code_paths:\n            try:\n                _copy_file_or_tree(src=code_path, dst=path, dst_dir=code_dir_subpath)\n            except OSError as e:\n                # A common error is code-paths includes Databricks Notebook. We include it in error\n                # message when running in Databricks, but not in other envs tp avoid confusion.\n                example = \", such as Databricks Notebooks\" if is_in_databricks_runtime() else \"\"\n                raise MlflowException(\n                    message=(\n                        f\"Failed to copy the specified code path '{code_path}' into the model \"\n                        \"artifacts. It appears that your code path includes file(s) that cannot \"\n                        f\"be copied{example}. Please specify a code path that does not include \"\n                        \"such files and try again.\",\n                    ),\n                    error_code=INVALID_PARAMETER_VALUE,\n                ) from e\n    else:\n        code_dir_subpath = None\n    return code_dir_subpath\n\n\ndef _infer_and_copy_code_paths(flavor, path, default_subpath=\"code\"):\n    # Capture all imported modules with full module name during loading model.\n    modules = _capture_imported_modules(path, flavor, record_full_module=True)\n\n    all_modules = set(modules)","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/utils/model_utils.py#L184-L220","documentation":"MLflow raises this MlflowException (INVALID_PARAMETER_VALUE) when copying a `code_paths` entry into the model artifacts fails with an OSError inside `_validate_and_copy_code_paths`. The underlying OS copy failed—typically because the path includes objects that cannot be copied like Databricks Notebook files, unreadable files, or broken symlinks.","triggerScenarios":"Including a Databricks Notebook in code_paths while running in Databricks; code_paths entry points to a file with no read permission; copying across filesystems with unsupported features; path disappearing mid-copy.","commonSituations":"Notebook-driven MLflow development on Databricks where the notebook itself is in code_paths; pip-installed or root-only files; network-mounted code directories that drop out during save.","solutions":["Remove non-copyable entries (e.g., Databricks Notebooks) from code_paths; point to regular .py files/directories only.","Check read permissions on each code_paths entry.","Verify each path exists and is a regular file or directory before saving.","If you need notebook code, extract it into a .py module first."],"exampleFix":"# before\ncode_paths=[\"utils.py\", \"My Notebook\"]  # notebook can't be copied\n# after\ncode_paths=[\"utils.py\", \"notebook_logic.py\"]  # extracted plain module","handlingStrategy":"validation","validationCode":"import os\nbad = [p for p in (code_paths or []) if not os.path.exists(p) or not (os.path.isfile(p) or os.path.isdir(p))]\nassert not bad, f\"Non-copyable or missing code paths: {bad}\"","typeGuard":"def is_copyable_path(p):\n    import os\n    return os.path.exists(p) and (os.path.isfile(p) or os.path.isdir(p)) and not os.path.islink(p) or not os.path.islink(p)","tryCatchPattern":"from mlflow.exceptions import MlflowException\ntry:\n    mlflow.sklearn.save_model(model, path, code_paths=code_paths)\nexcept MlflowException as e:\n    if \"Failed to copy the specified code path\" in str(e):\n        clean_paths = [p for p in code_paths if os.path.isfile(p) or os.path.isdir(p)]\n        mlflow.sklearn.save_model(model, path, code_paths=clean_paths)\n    else:\n        raise","preventionTips":["Never include Databricks Notebooks in code_paths; export logic to .py modules","Pre-validate every code_paths entry with os.path.exists and permission checks","Keep code_paths entries inside the project/workspace, not volatile mounts"],"tags":["mlflow","filesystem","code-paths","oserror"],"backgroundTag":"file-copy-failed","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}