#10738·livewire

livewire:configure-s3-upload-cleanup fails on R2/S3-compatible stores: lifecycle rule missing ID (MalformedXML)

Author: tonyputiCreated Sep 22, 2026Updated Sep 22, 2026

Description

php artisan livewire:configure-s3-upload-cleanup fails with MalformedXML against any S3-compatible store that validates lifecycle XML strictly — specifically Cloudflare R2, which also backs Laravel Cloud's managed object storage. The command submits a lifecycle rule without the ID element; AWS S3 treats ID as optional, but R2's schema requires it.

Reproduction

  1. Use any R2 (or R2-compatible) bucket as the upload disk (livewire.temporary_file_upload.disk or filesystems.default).
  2. Run php artisan livewire:configure-s3-upload-cleanup.
Failed to configure S3 bucket [<bucket>] to automatically cleanup files older than 24hrs!
Error executing "PutBucketLifecycleConfiguration" on "https://<bucket>.<account>.r2.cloudflarestorage.com/?lifecycle";
AWS HTTP error: MalformedXML (client): The XML you provided was not well formed or did not validate against our published schema.
  1. Running the identical putBucketLifecycleConfiguration call with 'ID' => 'anything' added to the rule succeeds against the same bucket with the same credentials.

Root cause

S3CleanupCommand::handle() builds the rule without an ID:

php
$rules[] = [
    'Filter' => [
        'Prefix' => $prefix,
    ],
    'Expiration' => [
        'Days' => 1,
    ],
    'Status' => 'Enabled',
];

R2 requires every rule to carry an ID (all of R2's own S3-API examples include one). The idempotency check in mergeRulesWithExistingConfiguration() compares Filter.Prefix, so adding an ID does not affect re-runs.

Suggested fix

Add an ID to the rule, e.g.:

php
$rules[] = [
    'ID' => 'livewire-tmp-cleanup',
    'Filter' => [
        'Prefix' => $prefix,
    ],
    'Expiration' => [
        'Days' => 1,
    ],
    'Status' => 'Enabled',
];

Optional per the AWS spec, so this is harmless on AWS S3 and fixes every R2-compatible store (R2, and by extension Laravel Cloud object storage).

Current workaround

Apply the lifecycle rule directly via the AWS SDK (or the provider's dashboard/API) with an ID set.

Environment

  • Livewire: v4.4.5
  • Laravel: 13.x, PHP 8.4
  • Storage: Cloudflare R2 via league/flysystem-aws-s3-v3 (Laravel Cloud managed bucket)