Skip to content

PrismaClientConstructorValidationError: Unknown property _originalClient provided to PrismaClient constructor. #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gcor opened this issue Jan 29, 2025 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@gcor
Copy link

gcor commented Jan 29, 2025

Hello! Could you kindly help me understand an issue I’m having with the Casbin adapter for Prisma@6?

"use strict";

import fp from "fastify-plugin";
import casbin from "fastify-casbin";
import { PrismaAdapter } from "casbin-prisma-adapter";

export default fp(
  async function (fastify, opts) {
    fastify.register(casbin, {
      model: "model.conf",
      adapter: await PrismaAdapter.newAdapter(fastify.prisma),
    });
  }, { dependencies: ["prisma"] }
);

Error: PrismaClientConstructorValidationError: Unknown property _originalClient provided to PrismaClient constructor.

@hsluoyz
Copy link
Member

hsluoyz commented Jan 29, 2025

@nodece @Shivansh-yadav13

@hsluoyz hsluoyz added the bug Something isn't working label Jan 29, 2025
@hsluoyz hsluoyz self-assigned this Jan 29, 2025
@gcor gcor closed this as completed Jan 29, 2025
@hsluoyz hsluoyz added invalid This doesn't seem right and removed bug Something isn't working labels Jan 30, 2025
@Luchanso
Copy link

The same issue

@hsluoyz
Copy link
Member

hsluoyz commented Mar 20, 2025

@Luchanso can you provide a full reproducible example code repo?

@Luchanso
Copy link

Luchanso commented Mar 24, 2025

This is a floating bug (now everything okey) and I'm sure this 100% in prisma-adapter, and I think problem can be with instanceof, when prisma client saved like "options" (not like instance of prisma client)

@wuhao1477
Copy link

After testing, I found that this issue doesn't occur with Prisma versions 6.0.0 and 6.1.0, but starts appearing in versions after 6.1.0. As mentioned in comment #62 (comment), the problem seems to be caused by the code at https://github.com/node-casbin/prisma-adapter/blob/master/src/adapter.ts#L27. I tried printing to the console and found that the result is false.

I believe this is related to how the instanceof check is handled when the Prisma client is saved as "options" rather than as an instance of the Prisma client. This explains why the behavior changes between different Prisma versions.

@hsluoyz
Copy link
Member

hsluoyz commented May 20, 2025

@Luchanso @wuhao1477 can you make a PR to fix it?

@hsluoyz hsluoyz reopened this May 20, 2025
@hsluoyz hsluoyz added bug Something isn't working and removed invalid This doesn't seem right labels May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants