From 5379aa234891f245eb5cb01b8b98fc2f4344c110 Mon Sep 17 00:00:00 2001 From: skshetry <18718008+skshetry@users.noreply.github.com> Date: Tue, 26 Mar 2024 17:01:35 +0545 Subject: [PATCH] add: raise DoesNotExistError only if the output path does not exist (#10373) `dvc add` command incorrectly raises a `DoesNotExistError` when a broken symlink exists in an output directory, and the target name is same as the directory's name. eg: If `data` is an output, and is the command is invoked as `dvc add data` (i.e. no virtual directory operations to perform). The expected behavior to raise a `FileNotFoundError`. `DoesNotExistError` should only be raised if the output itself does not exist. Related: https://github.com/iterative/dvc/issues/3717 --- dvc/output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dvc/output.py b/dvc/output.py index 92a982cc2..81f6880df 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -1365,7 +1365,7 @@ class Output: dry_run=not self.use_cache, ) except FileNotFoundError as exc: - if self.fs_path == path: + if not self.exists: raise self.DoesNotExistError(self) from exc if not self.is_dir_checksum: raise