Skip to content

🐛 Bug Report: S3 device fails with "Failed to decode S3 XML response" on S3-compatible providers that return an empty application/xml body #16025

Backlog

Description

@egortabula

👟 Reproduction steps

  1. Self-host Appwrite 2.7.4 with an S3-compatible provider (VK Cloud Object Storage, hb.ru-msk.vkcloud-storage.ru):
    _APP_STORAGE_DEVICE=s3
    _APP_STORAGE_S3_ENDPOINT=https://hb.ru-msk.vkcloud-storage.ru
    _APP_STORAGE_S3_BUCKET=<bucket>
    _APP_STORAGE_S3_REGION=ru-msk
    _APP_EXECUTOR_CONNECTION_STORAGE=s3://<key>:<secret>@hb.ru-msk.vkcloud-storage.ru/?region=ru-msk
    
  2. Upload any file to a bucket (POST /v1/storage/buckets/{bucketId}/files), or create a function deployment so the executor stores the build output.

👍 Expected behavior

The file is uploaded and the build is stored.

👎 Actual behavior

The request fails with Utopia\Storage\Exception\RemoteException: Failed to decode S3 XML response. The object is in fact written to the bucket; only the response handling fails.

The provider answers a successful single-part PUT like this:

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 0

S3::call() treats any application/xml response as XML and decodes it:

// packages/storage/src/Device/S3.php (2.7.4, line 1241-1246)
$isXml = $contentType === 'application/xml' || (str_starts_with($responseBody, '<?xml') && $contentType !== 'image/svg+xml');

return new S3\Response(
    code: $code,
    headers: $responseHeaders,
    body: $decode && $isXml ? $this->decodeXml($responseBody) : $responseBody,
);

For an empty body, decodeXml('') throws because simplexml_load_string('') returns false. The same code is in utopia-php/storage 4.4.0, which openruntimes/executor:1.3.7 bundles, so function builds fail as well. The code is unchanged on main as of 2026-11-24.

Stack trace (executor, while storing a build):

Utopia\Storage\Exception\RemoteException: Failed to decode S3 XML response
#0 vendor/utopia-php/storage/src/Device/S3.php(965): Utopia\Storage\Device\S3->decodeXml('')
...
Utopia\Storage\Device\S3->write(...)
Utopia\Storage\Device->copy(...)

Suggested fix

Skip decoding when the body is empty:

body: $decode && $isXml && $responseBody !== '' ? $this->decodeXml($responseBody) : $responseBody,

We applied this one-line change locally, mounted into the appwrite/appwrite services and the executor. Single-part and multipart uploads and downloads now work against VK Cloud Object Storage.

🎲 Appwrite version

Version 2.7.4 (self-hosted). Executor: openruntimes/executor:1.3.7. Upgraded from 1.9.6, which did not have this problem.

💻 Operating system

Linux (Ubuntu 22.04, Docker).

🧱 Your Environment

  • Storage: VK Cloud Object Storage (S3-compatible, path-style).
  • Database: MongoDB 8.2.5.

Related, possibly worth a separate issue

  1. Content-Encoding: aws-chunked on stored objects. Objects uploaded by Appwrite 1.9.6 to the same provider were stored with Content-Encoding: aws-chunked; the provider keeps the header, unlike AWS. The new HTTP client in executor 1.3.7 lets curl decode responses, and curl fails on those objects with Unrecognized content encoding type. We removed the header from existing build/source objects with an in-place copy (x-amz-metadata-directive: REPLACE).
  2. _APP_CONSOLE_DOMAIN dropped on upgrade. upgrade drops _APP_CONSOLE_DOMAIN from .env because it is not in app/config/variables.php. The generated docker-compose.yml still uses it in the Traefik console router rules (Host(\${_APP_CONSOLE_DOMAIN:-localhost}`)`) and passes it to several services, so a console on its own domain stops being routed after an upgrade unless the variable is re-added by hand.

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions