Skip to content

Inconsistent column data: Unexpected conversion failure for field Keys.private_key from String(...) to Bytes. Reason: Could not convert from base64 encoded bytes to PrismaValue::Bytes #23262

@aacoimbra

Description

@aacoimbra

Bug description

I've updated prisma to 5.10.2 and activated previewFeatures = ["relationJoins"].

Then my server started raising the following error:

PrismaClientKnownRequestError: 
Invalid `prisma.wallet.findUnique()` invocation:


Inconsistent column data: Unexpected conversion failure for field Keys.private_key from String(VALUE HERE) to Bytes. Reason: Could not convert from `base64 encoded bytes` to `PrismaValue::Bytes`      
    at _n.handleRequestError (...\node_modules\@prisma\client\runtime\library.js:123:6854)
    at _n.handleAndLogRequestError (...\node_modules\@prisma\client\runtime\library.js:123:6188)
    at _n.request (...\node_modules\@prisma\client\runtime\library.js:123:5896)
    at async l (...\node_modules\@prisma\client\runtime\library.js:128:10871)
    at async main (file:///.../src/test.ts:11:24) {
  code: 'P2023',
  clientVersion: '5.10.2',
  meta: {
    modelName: 'Wallet',
    message: 'Unexpected conversion failure for field Keys.private_key from String(VALUE HERE) to Bytes. Reason: Could not convert from `base64 encoded bytes` to `PrismaValue::Bytes`'
  }
}

Removing relationJoins solves the issue.

How to reproduce

  1. Have a base64 encoded bytes object stored in a Bytes field
  2. Try to retrieve this field

Expected behavior

Return of the stored field.

Prisma information

Here is are some relevant pieces of my prisma schema.

generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "rhel-openssl-1.0.x"]
  // previewFeatures = ["relationJoins"]
}

datasource db {
  provider     = "mysql"
  url          = env("DATABASE_URL")
  relationMode = "foreignKeys"
}

model Keys {
  id          String @id @default(uuid())
  public_key  String
  private_key Bytes
  index       Int

  wallet    Wallet @relation( fields: [wallet_id], references: [id])
  wallet_id String

  @@index([wallet_id])
}
const wallet = await prisma.wallet.findUnique({
	where: { id: id },
	include: { 
		keys:  true
	},
});

Environment & setup

  • OS: Amazon Linux 2 (also managed to replicate in windows 11)
  • Database: PlanetScale
  • Node.js version: Node.js 18.x

Prisma Version

prisma                  : 5.10.2
@prisma/client          : 5.10.2
Computed binaryTarget   : windows
Operating System        : win32
Architecture            : x64
Node.js                 : v18.17.0
Query Engine (Node-API) : libquery-engine 5a9203d0590c951969e85a7d07215503f4672eb9 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Schema Engine           : schema-engine-cli 5a9203d0590c951969e85a7d07215503f4672eb9 (at node_modules\@prisma\engines\schema-engine-windows.exe)
Schema Wasm             : @prisma/prisma-schema-wasm 5.10.0-34.5a9203d0590c951969e85a7d07215503f4672eb9
Default Engines Hash    : 5a9203d0590c951969e85a7d07215503f4672eb9
Studio                  : 0.499.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions