Copilot commented on code in PR #74943:
URL: https://github.com/apache/airflow/pull/74943#discussion_r4744437703
##########
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 (
+ self.protocol == path.protocol
+ and self.bucket == path.bucket
+ and (not self.key or self.key == path.key or
path.key.startswith(f"{self.key}/"))
Review Comment:
Moving `s3://conn_a@bucket/src` to `s3://conn_b@bucket/` passes this guard
even when both connections access the same storage. The directory copy
preserves full source keys, so it writes `src/*` back onto itself and the
recursive removal deletes the data. Check the effective copy destinations for
overlap before copying, and add a regression test with `src_key='src',
dst_key=''`.
##########
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 (
+ self.protocol == path.protocol
Review Comment:
Moving `s3://bucket/src` to `s3a://bucket/src/archive` on the same backend
bypasses this guard, allowing the recursive removal to delete both the
originals and the copies. The Amazon provider registers both aliases in
`providers/amazon/src/airflow/providers/amazon/aws/fs/s3.py:42`, and [UPath's
default-branch test at
ce63a56](https://github.com/fsspec/universal_pathlib/blob/ce63a56cd741f50a1d463c525e0295d20bfbe7f8/upath/tests/test_core.py#L489-L495)
confirms their protocol strings remain distinct. Account for equivalent
protocols when checking storage identity and containment, and add an alias
regression test.
##########
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 (
+ self.protocol == path.protocol
+ and self.bucket == path.bucket
+ and (not self.key or self.key == path.key or
path.key.startswith(f"{self.key}/"))
Review Comment:
A bucket name is not globally unique across different S3-compatible
endpoints. Each connection can select its own `endpoint_url` in
`providers/amazon/src/airflow/providers/amazon/aws/fs/s3.py`, so moving
`s3://primary@bucket/report.txt` to `s3://backup@bucket/report.txt` can be a
valid transfer between independent stores. This condition now rejects that
previously working file move as a self-move. Establish whether the connections
address the same underlying namespace before applying the key-containment
check, and cover distinct endpoints with identical bucket/key names.
--
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]