Skip to content

AWS.RDS.Aurora: Data API migrations fail under alchemy dev, and the transport silently falls back to direct #2997

Description

@xofromthemoon

Summary

Under alchemy dev, an AWS.RDS.Aurora with migrations and the default transport cannot migrate against Floci, for two reasons on Alchemy's side.

  1. Alchemy picks the transport from the cluster's observed HttpEndpointEnabled, not from dataApi. Floci never reports that field, so Alchemy switches to direct without a word. The "data-api" default is documented, but it does not hold here. The direct connection then goes to 127.0.0.1:5432, where Floci is not listening.
  2. With the Data API transport, the migration executor always sends formatRecordsAs: "JSON". Floci rejects that with a 400, so the first query fails before any DDL runs.

Floci's Data API itself works without the flag. On 2.1.0-alchemy.3, statements, a transaction and DDL all succeeded against a cluster that does not report HttpEndpointEnabled, so only these two checks stand in the way. RDSData.toRows already builds rows from records and columnMetadata, and that request shape is valid on AWS too.

What happened

Our app runs Aurora PostgreSQL in deployed stages and a Postgres container under alchemy dev. To drop that container, we deployed the app's Aurora props against Floci under alchemy dev semantics (Test.make({ dev: true })). Those props are: aurora-postgresql 18.6, Serverless v2 0–1 ACU, storageEncrypted with kmsKeyId, secret: { resource }, a db.serverless writer, and drizzle-kit migrations.

With the default transport (no migrationsTransport), the writer failed:

[Aurora/Writer] fail (local) — MigrationError: Failed to connect to <cluster>.cluster-<hash>.us-east-1.rds.localhost.floci.io:5432: The server does not support SSL connections (10.4s)

The server that answered is the app's own dev Postgres container on 127.0.0.1:5432, not Floci. Nothing in the log says the migrations had switched to a direct connection. A server with TLS and matching credentials would have received the migration DDL.

With migrationsTransport: "data-api":

[Aurora/Writer] fail (local) — MigrationError: DB cluster '<cluster>' does not have the Data API enabled (set enableHttpEndpoint: true) (73ms)

Aurora had created the cluster with enableHttpEndpoint: true.

With HttpEndpointEnabled faked in DescribeDBClusters by an in-process fetch shim, the Data API transport ran and failed on its first query:

[Aurora/Writer] fail (local) — MigrationError: Data API query failed: formattedRecords is not supported by this local RDS Data API implementation. (10.2s)

A second shim then answered formatRecordsAs: "JSON" by sending includeResultMetadata: true instead and building formattedRecords from the reply. With both shims, the unchanged props deployed in one pass: Done: 22 succeeded (14.7s). Migrations were applied over the Data API: 25 tables, pg_trgm, and both rows in __alchemy_migrations. A redeploy was a no-op, and destroy was clean. Those shim runs were on beta.84.

On beta.85 with the same image, raw API calls still show both refusals: EnableHttpEndpoint answers UnsupportedOperation, and formatRecordsAs: "JSON" answers 400 BadRequestException.

Cause

Links are to main at 2e423dd.

Suggested fix

  1. Executor: drop formatRecordsAs, send includeResultMetadata: true, and map results with toRows. It is one request shape on both AWS and Floci. We ran a copy of the executor changed this way against Floci, and it applied the same migrations.
  2. Transport: make the documented default hold, so a cluster with dataApi enabled never falls back to connecting from the deploying machine to wherever the endpoint resolves. At a minimum, log the chosen transport and the reason when it differs from the documented default.
  3. Test: cover the Aurora migrations path in the Floci lane.

Fix 1 alone does not unblock Floci, because the default stays direct while Floci omits HttpEndpointEnabled. Fixing only the Floci side moves the failure onto formatRecordsAs.

Workaround

None that we verified. Pinning migrationsTransport: "direct" needs a host route to the endpoint, and the managed alchemy-floci container does not publish 5432. An AWS.RDS.MigrationRunner Lambda inside Floci might avoid both problems, but we have not tried it. We keep a Postgres container for alchemy dev.

Out of scope

Replacing that container takes more than migrations. Hosts have no route to the emulated cluster, and its data does not survive a Floci restart (see #2724 and #2822).

Seen on @alchemy.run/aws 2.0.0-beta.84 and 2.0.0-beta.85, floci image ghcr.io/alchemy-run/floci:2.1.0-alchemy.3, Linux x86_64.

Activity

  1. mmhand123 commented on Nov 6, 2026

    @mmhand123

    Not sure if it warrants another issue, but ran into a similar problem when just trying to connect to a floci RDS db. Worked around it for now by patching the floci package to publish port 5432. Wondering if I'm doing something wrong though in terms of using RDS via floci locally? Or is the plan to update floci to listen on that port?

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