amoghrajesh commented on code in PR #74943:
URL: https://github.com/apache/airflow/pull/74943#discussion_r4753047645


##########
task-sdk/src/airflow/sdk/io/path.py:
##########
@@ -461,9 +461,19 @@ def move(self, path: str | ObjectStoragePath, recursive: 
bool = False, **kwargs)
             get_hook_lineage_collector().add_output_asset(context=path, 
uri=str(path))
             return self.fs.move(self.path, path.path, recursive=recursive, 
**kwargs)
 
+        if (

Review Comment:
   The guard treats the same protocol and bucket name as the same store, 
ignoring `conn_id` and endpoint. A move from `s3://primary@bucket/report.txt` 
to `s3://backup@bucket/report.txt` now raises `ValueError`. It worked before. 
Azure containers and S3 compatible endpoints reuse bucket names, so this is a 
real backward compat break. Compare the real backends instead (for `example 
self.fs` == `path.fs`) and keep the move working when they differ



##########
task-sdk/tests/task_sdk/io/test_path.py:
##########
@@ -349,6 +363,53 @@ def test_bucket_key_protocol(self):
         assert o.key == key
         assert o.protocol == protocol
 
+    @pytest.mark.parametrize("src_key", ["src", "x/src"])
+    @mock.patch.object(_FakeRemoteFileSystem, "mkdir", autospec=True)
+    def test_copy_dir_to_new_remote_dir(self, mock_mkdir, src_key, 
fake_remote_stores):
+        bucket = uuid.uuid4().hex
+        src = ObjectStoragePath(f"ffs://{bucket}/{src_key}")
+        for name in ("a.txt", "b.txt"):
+            (src / name).write_text(name)
+        dst = ObjectStoragePath(f"ffs2://{bucket}/dst")
+
+        src.copy(dst, recursive=True)
+
+        assert (dst / src_key / "a.txt").read_text() == "a.txt"
+        assert (dst / src_key / "b.txt").read_text() == "b.txt"
+
+    @pytest.mark.parametrize(
+        ("src_key", "dst_key"),
+        [
+            ("src", "src"),
+            ("src", "src/archive"),
+            ("", "archive"),
+        ],
+    )
+    def test_move_dir_into_itself_across_conn_ids_raises(self, src_key, 
dst_key, fake_remote_stores):

Review Comment:
   This locks in the false positive from line 464. It also has no case for a 
destination at the bucket root, which is the data-loss path. Add the root case, 
and add a case that two connections with different endpoints can still move.



##########
task-sdk/tests/task_sdk/io/test_path.py:
##########
@@ -460,6 +521,18 @@ def test_move_local(self, hook_lineage_collector, 
tmp_path, target):
         assert collected_assets.inputs[0].asset.uri == str(o1)
         assert collected_assets.outputs[0].asset.uri == str(o2)
 
+    def test_move_dir_local_to_remote(self, tmp_path, fake_remote_stores):

Review Comment:
   The headline fix is a remote to remote directory move that now succeeds 
through `fs.rm`. No test runs that.` test_move_dir_local_to_remote` only covers 
local to remote. Add `test_move_dir_remote_to_remote_removes_source` with `ffs` 
and `ffs2` and assert the source is gone and `dst/src/a.txt` exists.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to