Skip to content

adapter-neon: PrismaNeonHttp passes query args unmapped — Bytes params silently corrupted, DateTime params get local-timezone skew #29743

Closed

Description

@gordyf

Bug description

PrismaNeonHttpAdapter.performIO (in @prisma/adapter-neon) passes query arguments to the Neon HTTP client without running them through mapArg, while the WebSocket adapter (NeonWsQueryable.performIO) maps every argument:

// NeonWsQueryable.performIO (WebSocket) — correct
const result = await this.client.query(
  { text: sql, rowMode: 'array', types: { ... } },
  args.map((arg, i) => mapArg(arg, query.argTypes[i]))   // ✅
);

// PrismaNeonHttpAdapter.performIO (HTTP) — args passed through raw
const { sql, args: values } = query;
return await this.client(sql, values, { arrayMode: true, fullResults: true, types: { ... } });  // ❌ no mapArg

The query engine hands the adapter Bytes arguments as base64 strings and DateTime arguments as ISO strings / Date objects — mapArg is what converts them to driver-ready values. Skipping it causes two silent data-corruption bugs on the HTTP adapter:

  1. Bytes parameters are stored and compared as literal base64 text. The base64 string reaches Postgres as a plain text param on a bytea column, which interprets it in escape format — so the text characters of the base64 encoding are stored (e.g. 32 bytes stored for a 24-byte value). Writes are silently corrupted, and any filter on a Bytes column never matches rows containing correct raw bytes (rows written by anything other than the HTTP adapter itself). No error is raised anywhere.

    Real-world impact: this broke all WebAuthn/passkey logins on our production site after migrating to Prisma — credential.findUnique({ where: { credentialId } }) silently returned null for every stored credential, and newly registered credentials were stored with corrupted credentialId/publicKey.

  2. Date parameters are serialized with the process's local timezone offset. Unmapped Date objects fall through to the Neon driver's pg-style prepareValue, which renders local time with an offset suffix (e.g. 2026-07-20T20:08:28.709-07:00); a timestamp (without time zone) column silently drops the offset, storing local wall-clock time while reads assume UTC. Every DateTime write is skewed by the process's UTC offset in any non-UTC runtime (e.g. expiresAt values land 7 hours in the past in a PDT dev environment).

Reproduced on @prisma/adapter-neon 7.8.0 and 7.9.0.

Severity

🚨 Critical: Data loss, app crash, security issue

(Silent corruption of every Bytes write and silent mismatch of every Bytes filter through the HTTP adapter; no error surfaced.)

Reproduction

Schema:

model Thing {
  id   Int   @id
  blob Bytes
}

Script (any Neon database URL, or Neon's serverless protocol via the local-neon-http-proxy docker image in front of a local Postgres):

import { PrismaNeonHttp } from '@prisma/adapter-neon';
import { PrismaClient } from './generated/client.js';

const db = new PrismaClient({ adapter: new PrismaNeonHttp(process.env.DATABASE_URL, {}) });

// 1. Bytes writes are corrupted:
const bytes = Buffer.from('hello-raw-bytes'); // 15 bytes
await db.thing.create({ data: { id: 1, blob: bytes } });
const [row] = await db.$queryRaw`
  SELECT octet_length("blob") AS len, encode("blob", 'hex') AS hex FROM "Thing" WHERE id = 1`;
console.log(Number(row.len));                       // 20  (base64 text length) — expected 15
console.log(row.hex === bytes.toString('hex'));     // false — stored bytes are the base64 *text*

// 2. Bytes filters never match correctly-stored rows (e.g. written before a migration to Prisma):
await db.$executeRaw`INSERT INTO "Thing" (id, blob) VALUES (2, '\x0102030405'::bytea)`;
console.log(await db.thing.findFirst({ where: { blob: Buffer.from([1, 2, 3, 4, 5]) } })); // null — expected the row

// 3. DateTime skew (run with a non-UTC TZ, e.g. TZ=America/Los_Angeles):
//    create a row with a DateTime field and read it back — the value shifts by the UTC offset.

All three behave correctly with the WebSocket adapter (PrismaNeon), and all three are fixed by adding the same mapArg call the WebSocket path uses:

   async performIO(query) {
-    const { sql, args: values } = query;
+    const { sql, args } = query;
+    const values = args.map((arg, i) => mapArg(arg, query.argTypes[i]));
     return await this.client(sql, values, {

We validated this fix end-to-end (bytea round-trip byte-exact, cross-written rows found by findUnique, timestamps stored in UTC).

Expected vs. Actual Behavior

Expected: Bytes values round-trip byte-exact and match bytea values written by other clients; DateTime values are stored in UTC regardless of process timezone — i.e. the HTTP adapter behaves like the WebSocket adapter.

Actual: Bytes values are stored as the base64 text of the intended bytes and never match correctly-stored rows in filters; Date params are rendered in local time, which naive timestamp columns keep after dropping the offset. No errors are raised.

Frequency

Consistently reproducible

Does this occur in development or production?

Both development and production

Is this a regression?

Not a regression within Prisma 7 as far as we can tell — present in both 7.8.0 and 7.9.0 (older versions not tested). The mapping exists and works in the WebSocket adapter in the same file, so it appears the HTTP path was simply missed. Possibly related history: #25514 fixed the result-decoding direction for PrismaNeonHTTP by adding custom type parsers; this issue is the same asymmetry in the parameter-encoding direction.

Workaround

Patch the package (e.g. pnpm patch @prisma/adapter-neon) to add the missing mapping in PrismaNeonHttpAdapter.performIO, in both dist/index.js and dist/index.mjs:

   async performIO(query) {
-    const { sql, args: values } = query;
+    const { sql, args } = query;
+    const values = args.map((arg, i) => mapArg(arg, query.argTypes[i]));
     return await this.client(sql, values, {

Alternatively, use the WebSocket adapter (PrismaNeon) instead of the HTTP one, at the cost of per-request connection setup in serverless environments.

Prisma Schema & Queries

model Credential {
  id           String @id @default(uuid(7)) @db.Uuid
  credentialId Bytes  @unique
  publicKey    Bytes
  // ...
}
// silently returns null for any row whose bytea was written with correct raw bytes:
await db.credential.findUnique({ where: { credentialId: someBuffer } });

// silently stores base64 text bytes instead of the given bytes:
await db.credential.create({ data: { credentialId: idBuffer, publicKey: keyBuffer /* ... */ } });

Prisma Config

// prisma.config.ts — nothing unusual; client generated with the `prisma-client` generator.
// Adapter constructed as:
import { PrismaNeonHttp } from '@prisma/adapter-neon';
const adapter = new PrismaNeonHttp(process.env.DATABASE_URL, {});
const db = new PrismaClient({ adapter });

Logs & Debug Info

No errors are emitted anywhere — that is part of the problem. Writes succeed
(with corrupted bytes) and filters succeed (returning null / no rows).

Environment & Setup

  • OS: macOS (dev) / Cloudflare Workers (prod) — bytea corruption reproduces on both; the DateTime skew needs a non-UTC process TZ
  • Database: PostgreSQL (Neon serverless, HTTP transport)
  • Node.js version: v22 / v24

Prisma Version

prisma               : 7.8.0
@prisma/client       : 7.8.0
Operating System     : darwin
Architecture         : arm64
Node.js              : v22.23.1
TypeScript           : 6.0.3

(also reproduced against @prisma/adapter-neon 7.9.0)

Activity

  1. santichausis commented on Jul 21, 2026

    @santichausis
    Contributor

    I'd like to take this on — opening a PR shortly that applies the same mapArg mapping the WebSocket path already uses, to PrismaNeonHttpAdapter.performIO.

  2. added a commit that references this issue on Jul 22, 2026
    272078a
  3. added a commit that references this issue on Aug 9, 2026
    5c324ce
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