Skip to content

FileFetchTask ignores write failures and deletes the source file with remove_source #35

Description

@njoubert-cleverage

Description

FileFetchTask silently ignores write failures on the destination storage, which can lose data:

  • the error thrown by writeStream() is caught and discarded: no log, no exception, the process succeeds;
  • the task still outputs the file name, as if the copy had succeeded;
  • with remove_source: true, the source file is deleted although it was never copied.

Reproduction

local.storage.fetch_failure is a local storage in which demo_fetch_write_failure.txt is a directory, so the write fails:

clever_age_process:
    configurations:
        demo.flysystem.fetch_write_failure:
            tasks:
                content:
                    service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
                    options:
                        output: 'Some important data'
                    outputs: [write_source]
                write_source:
                    service: '@CleverAge\ProcessBundle\Task\File\FileWriterTask'
                    options:
                        filename: '%local.storage.dir%/demo_fetch_write_failure.txt'
                    outputs: [block_destination]
                block_destination:
                    service: '@CleverAge\ProcessBundle\Task\File\FileWriterTask'
                    options:
                        filename: '%kernel.project_dir%/var/storage/fetch_failure/demo_fetch_write_failure.txt/blocker'
                    outputs: [filename]
                filename:
                    service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
                    options:
                        output: 'demo_fetch_write_failure.txt'
                    outputs: [fetch]
                fetch:
                    service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
                    options:
                        source_filesystem: 'local.storage'
                        destination_filesystem: 'local.storage.fetch_failure'
                        remove_source: true
                    outputs: [debug]
                debug:
                    service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask'
$ bin/console cleverage:process:execute demo.flysystem.fetch_write_failure
"demo_fetch_write_failure.txt"
Process 'demo.flysystem.fetch_write_failure' executed successfully
$ ls var/storage/local/demo_fetch_write_failure.txt
ls: cannot access 'var/storage/local/demo_fetch_write_failure.txt': No such file or directory

Expected: the task fails with the write error (the error_strategy applies) and the source file is kept.

Tested on main (5e8488f), cleverage/process-bundle 5.1, PHP 8.5, Symfony 7.4.

Cause

FileFetchTask::doFileCopy() catches FilesystemException around writeStream(), then deletes the source whatever the result. execute() ignores the value returned by doFileCopy().

Activity

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

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions