Skip to content

Happy Server - Standalone Docker setup fails: PGlite can't handle Uint8Array for Prisma Bytes column in machinesRoutes.ts #612

Description

@gaius-codius

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:

  1. Run a Postgres container
  2. Push the schema: npx prisma db push --schema=packages/happy-server/prisma/schema.prisma
  3. 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

Activity

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

    • Status
      In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions