Bug
The standalone Docker setup (using PGlite) fails immediately when the daemon tries to register a machine. POST /v1/machines returns 500 on every attempt.
Error
PrismaClientKnownRequestError: P2023
Invalid prisma.machine.findFirst() invocation:
Inconsistent column data: Conversion failed: expected a string or an array
in column 'dataEncryptionKey', found {"0":0,"1":135,"2":49,...}
Cause
In packages/happy-server/sources/app/api/routes/machinesRoutes.ts line 62:
dataEncryptionKey: dataEncryptionKey ? new Uint8Array(Buffer.from(dataEncryptionKey, 'base64')) : undefined,
Uint8Array gets serialized as a JSON object ({"0":0,"1":135,...}) instead of binary data. PGlite's Prisma adapter (pglite-prisma-adapter) doesn't handle Uint8Array for Bytes
columns.
Fix
Replace new Uint8Array(Buffer.from(...)) with just Buffer.from(...):
dataEncryptionKey: dataEncryptionKey ? Buffer.from(dataEncryptionKey, 'base64') : undefined,
Workaround
Use an external PostgreSQL instead of PGlite:
- Run a Postgres container
- Push the schema: npx prisma db push --schema=packages/happy-server/prisma/schema.prisma
- Start the server with DATABASE_URL=postgresql://... and PGLITE_DIR= (empty, to override the Dockerfile default)
Note: PGLITE_DIR is baked into the Dockerfile as ENV PGLITE_DIR=/data/pglite. db.ts checks PGLITE_DIR before DATABASE_URL, so you must explicitly unset it or the server will still
use PGlite even with DATABASE_URL set.
Environment
- Happy CLI: 0.13.0
- Platform: Linux x64
- Node.js: v22.16.0
- Docker image: built from main branch per README instructions
Bug
The standalone Docker setup (using PGlite) fails immediately when the daemon tries to register a machine.
POST /v1/machinesreturns 500 on every attempt.Error
PrismaClientKnownRequestError: P2023
Invalid prisma.machine.findFirst() invocation:
Inconsistent column data: Conversion failed: expected a string or an array
in column 'dataEncryptionKey', found {"0":0,"1":135,"2":49,...}
Cause
In
packages/happy-server/sources/app/api/routes/machinesRoutes.tsline 62:Fix
Replace new Uint8Array(Buffer.from(...)) with just Buffer.from(...):
dataEncryptionKey: dataEncryptionKey ? Buffer.from(dataEncryptionKey, 'base64') : undefined,
Workaround
Use an external PostgreSQL instead of PGlite:
Note: PGLITE_DIR is baked into the Dockerfile as ENV PGLITE_DIR=/data/pglite. db.ts checks PGLITE_DIR before DATABASE_URL, so you must explicitly unset it or the server will still
use PGlite even with DATABASE_URL set.
Environment