Skip to content

[export feature] S3 bucket 403 Forbidden while running exports #40296

@sheepfy

Description

@sheepfy

Preconditions and environment

Magento latest

Steps to reproduce

  1. setup S3 remote storage in app/etc/env.php (or whereever this can be set)
    'remote_storage' => [
        'driver' => 'aws-s3',
        'config' => [
            'bucket' => 'my-bucket',
            'region' => 'my-region',
            'credentials' => [
                'key' => 'my-key',
                'secret' => 'my-secret'
            ]
        ],
    ],
  1. Go to admin panel ->System -> Data Transfer -> Export
  2. Select Products & CSV (probably replicable with anything in here)
  3. Setup the crons or manually run the queue bin/magento queue:consumers:start exportProcessor

Expected result

No error logs

Actual result

Error logs

[2025-11-17T10:42:30.700718+00:00] report.ERROR: Unable to write file at location: import_export/./. Error executing "PutObject" on "https://my-bucket.amazonaws.com/import_export/./"; AWS HTTP error: Client error: `PUT https://my-bucket.amazonaws.com/import_export/./` resulted in a `403 Forbidden` response

Additional information

Stack trace
vendor/magento/module-import-export/Model/Export.php :: _getWriter
- this calls $this->_writer = $this->_exportAdapterFac->create($fileFormats[$this->getFileFormat()]['model']);
vendor/magento/module-import-export/Model/Export/Adapter/AbstractAdapter.php :: __construct
- this calls $this->_init()
vendor/magento/module-import-export/Model/Export/Adapter/Csv.php :: _init()
- this calls $this->_fileHandler = $this->_directoryHandle->openFile($this->_destination, 'w');
vendor/magento/framework/Filesystem/Directory/Write.php :: openFile
- this has $path as a filename something like "importexport_691af13f4e84b" therefore the dirname('...') returns dot . and S3 doesn't like dots.

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Import / exportComponent: ImportExportIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Reported on 2.4.xIndicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    Status

    Ready for Development

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions