Skip to content

[findFirst] cannot take negative one #28107

@jay-l-e-e

Description

@jay-l-e-e

Bug description

PrismaClientKnownRequestError: \nInvalid `prisma.audit.findFirst()` invocation:\n\n\nInput error. The 'findFirst' operation cannot be used with a 'take' argument that isn't 1
model.findFirst({ ..., take: -1 });

Severity

🚨 Critical: Data loss, app crash, security issue

Reproduction

Just try findFirst with take: -1

Expected vs. Actual Behavior

Expected: No error
Actual: Error

Frequency

Consistently reproducible

Does this occur in development or production?

Production and development

Is this a regression?

I'm not sure, but it seems to have worked before version 6.9.0.

Workaround

IDK

Prisma Schema & Queries

model Audit {
  id         Bytes       @id @database.ByteA
}
await Audit.findFirst({
  ...findConditions,
  skip: 0,
  take: before ? -1 : 1,
});

Prisma Config

import { join } from 'node:path';

import 'dotenv/config';

import type { PrismaConfig } from 'prisma';

export default {
  schema: join('sources', 'domains'),
  migrations: {
    path: join('sources', 'migrations'),
  },
} satisfies PrismaConfig;

Logs & Debug Info

PrismaClientKnownRequestError: \nInvalid `prisma.audit.findFirst()` invocation:\n\n\nInput error. The 'findFirst' operation cannot be used with a 'take' argument that isn't 1

Environment & Setup

  • OS: MacOs, Windows, Linux Alpine
  • Database: PostgreSQL
  • Node.js version: 22 LTS

Prisma Version

6.16.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions