Skip to content

GCSToGCSOperator: move_object=True raises NotFound (404) exception on task retry when source object was already deleted #72264

Closed

Description

@chateletlealSephora

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

Activity

  1. added
    kind:bug
    needs-triage
    on Aug 29, 2026
  2. boring-cyborg commented on Aug 29, 2026

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

  3. added
    provider:google
    on Aug 29, 2026
  4. added
    contributors-workshop
    and removed
    needs-triage
    contributors-workshop
    on Aug 30, 2026
  5. self-assigned this
    on Aug 30, 2026
  6. jroachgolf84 commented on Aug 30, 2026

    @jroachgolf84
    Collaborator

    Opened a PR to address this: #72275

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:providersgood first issuekind:bugprovider:google

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions