chateletlealSephora opened a new issue, #72264:
URL: https://github.com/apache/airflow/issues/72264

   ### Under which category would you file this issue?
   
   Airflow Core
   
   ### Apache Airflow version
   
   3.2.2
   
   ### What happened and how to reproduce it?
   
   When running GCSToGCSOperator with move_object=True, if a task fails after 
the file has been successfully copied and deleted from the source bucket (e.g., 
not acknowledge due to network issue), a task retry will attempt to delete the 
source object again.
   
   Because the object was already deleted in the previous run, the 
hook.delete() call raises a google.api_core.exceptions.NotFound (404) error, 
causing the task retry to fail completely rather than succeeding idempotently.
   
   Logs of error:
   ```
   [2026-08-28 19:07:45] INFO - Object application/interface/myfile.xml in 
bucket professional-bucket-europe-west1-in rewritten to object ...
   [2026-08-28 19:07:45] INFO - Blob application/interface/myfile.xml deleted.
   [2026-08-28 19:07:45] INFO - Executing copy of ...
   ...
   [2026-08-28 19:07:55] WARNING - Blob application/interface/myfile.xml in 
bucket professional-bucket-europe-west1-in does not exist.
   [2026-08-28 19:07:55] ERROR - Task failed with exception
   [STACK]
   google.api_core.exceptions.NotFound: 404 DELETE 
https://storage.googleapis.com/storage/v1/b/professional-bucket-europe-west1-in/o/application%2Finterface%myfile.xml?prettyPrint=false:
 No such object: 
professional-bucket-europe-west1-in/application/interface/myfile.xml
   ```
   
   Usually it takes less than a second to copy and delete but here I see in 
logs a gap of 10s. And at 2026-08-28 19:07:55 it tries again and fails
   
   ### What you think should happen instead?
   
   I think the issue is in hook.delete() inside _copy_single_object.
   
   It should catch google.api_core.exceptions.NotFound (404) when 
move_object=True and treat it as a successful deletion (with a warning log and 
proceed to next element), making move_object safely idempotent on retries.
   
   I expect to not have operator failure due to one element with this 404 Not 
Found but instead a successful task with 1 warning log.
   
   I think about this simple solution
   Replace this
   ```
   if self.move_object:
       hook.delete(self.source_bucket, source_object)
   ```
   
   By this
   ```
   if self.move_object:
       try:
           hook.delete(self.source_bucket, source_object)
       except Exception as e:
           from google.api_core.exceptions import NotFound
           if isinstance(e, NotFound):
               self.log.warning(
                   "Object %s/%s already deleted (404 on move); skipping.",
                   self.source_bucket,
                   source_object,
               )
           else:
               raise
   
   ```
   
   ### Operating System
   
   _No response_
   
   ### Deployment
   
   Google Managed Service for Apache Airflow
   
   ### Apache Airflow Provider(s)
   
   google
   
   ### Versions of Apache Airflow Providers
   
   22.2.0
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   Not Applicable
   
   ### Helm Chart configuration
   
   _No response_
   
   ### Docker Image customizations
   
   _No response_
   
   ### Anything else?
   
   Problem occurs when we have more than 1000 elements to move. Maybe once a 
day for 24 runs.
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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