Skip to content

Incorrect URL Format in AWS S3 File Uploads #1625

Closed

Description

@AndryHTC

Describe the bug
There is a critical bug in Serverpod (version 1.1.1) related to file uploads with AWS S3. The issue stems from an incorrect format in the "description" URL, where the S3 domain and the region are incorrectly concatenated using a dash ("-") instead of a dot ("."). This formatting error leads to unsuccessful file uploads, as the expected format should be "....s3.[region]..." but it incorrectly appears as "....s3-[region]...".

To Reproduce

  1. Set up Serverpod (version 1.1.1) for file uploads to AWS S3.
  2. Initiate a file upload to S3 using the Serverpod framework.
  3. Observe the error during the upload process, specifically focusing on the URL format used to access the S3 endpoint.
  4. The URL is incorrectly formatted, using a dash to separate the S3 domain and region, resulting in a failed upload.

Expected behavior
The expected behavior is a seamless and successful file upload to AWS S3 when using Serverpod 1.1.1. The URL should be formatted correctly, chaining the S3 domain with the region using a dot (.), i.e., "....s3.[region]...".

Serverpod versions

  • CLI Version: 1.1.1
  • Library version: 1.1.1

Platform information
Windows, Mac

Additional context
This issue is critical as it hinders basic file upload functionality with AWS S3, a common use case for Serverpod applications. Prompt attention and a fix would be greatly appreciated to ensure smooth operation and integration with AWS services.

It's crazy that nobody ever found this bug in months.

Activity

  1. added
    bug
    on Dec 6, 2023
  2. dsvishchov commented on Apr 3, 2024

    @dsvishchov

    Any updates on this? Still not working in 1.2.6

  3. moved this to Bug fixes 🪲 in Serverpod Frameworkson Jun 13, 2024
  4. added
    area: storage
    on Dec 19, 2024
  5. realmeylisdev commented on Jun 11, 2026

    @realmeylisdev
    Contributor

    TL;DR: This is fixed as of Serverpod 3.4.0, via #4771. Upgrading resolves it.

    The bug was real

    The S3 endpoint was built by a vendored helper that hard-coded the legacy dash-style host. At the reported version (1.1.1), all three code paths in aws_s3_upload.dart used it — uploadFile (L35), uploadData (L97), and getDirectUploadDescription (L161), the last of which generates the upload description URL this issue describes:

    final endpoint = 'https://$bucket.s3-$region.amazonaws.com';

    So both server-side uploads and direct file uploads were affected.

    Why only some users hit it

    AWS supports the legacy s3-<region>.amazonaws.com syntax only in a handful of older regions (see the legacy endpoints notes in the AWS S3 endpoint reference). In those regions (e.g. us-west-2, eu-west-1) the dash-style URL happens to work, which is why the bug went unnoticed by many users. In every other region the host is rejected and uploads fail — exactly the symptom reported here (and the likely root cause of #2655 as well).

    The fix

    #4771 (merged 2026-03-03, released in 3.4.0) removed the vendored aws_s3_upload/aws_s3_client code entirely and rebuilt the S3 integration on the shared serverpod_cloud_storage_s3_compat package. Endpoint construction now uses the correct virtual-hosted style with a dot, in AwsEndpointConfig:

    Uri buildBucketUri(String bucket, String region) =>
        Uri.https('$bucket.s3.$region.amazonaws.com', '/');

    The same dot format is used for public file URLs (L32), and createDirectFileUploadDescription routes through this endpoint config, so the upload description URL is now correct too.

    Verification

    • The dash format was present continuously from 1.1.1 up to the commit just before #4771 merged — consistent with the 1.2.6 report above; every release before 3.4.0 was affected, and no earlier partial fix existed.
    • A repo-wide search on current main finds no remaining s3-<region>-style hosts in any storage package.
    • git tag --contains confirms the fix is in every release from 3.4.0 onward.

    Given that, this issue can be closed as fixed in 3.4.0 — for anyone hitting this on an older version, upgrading to ≥3.4.0 is the resolution.

  6. marcelomendoncasoares commented on Jun 11, 2026

    @marcelomendoncasoares
    Collaborator

    Thanks for your investigation on this, @realmeylisdev! Closing the issue then.

  7. moved this from Backlog 🗂️ to Done 🚀 in Serverpod Frameworkson Jun 11, 2026
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

    area: storagebug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions