prisma/prisma ยท critical

PSL_SCHEMA_READ_FAILED

PSL_SCHEMA_READ_FAILED

Error message

Failed to read Prisma schema at "${schemaPath}"

What it means

During the provider `load` phase, readFile(schemaPath) threw (ENOENT, EACCES, EISDIR, etc.) and could not return the PSL source text. The diagnostic carries the raw underlying error string as its message, and the notOk result summary echoes the schema path. Interpretation never starts because there is no source to parse.

Source

Thrown at packages/2-sql/2-authoring/contract-psl/src/provider.ts:112

      });
    },
    async load(context) {
      const [absoluteSchemaPath] = context.resolvedInputs;
      if (absoluteSchemaPath === undefined) {
        throw new InternalError(
          'prismaContract: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.',
        );
      }
      let schema: string;
      try {
        schema = await readFile(absoluteSchemaPath, 'utf-8');
      } catch (error) {
        const message = String(error);
        return notOk({
          summary: `Failed to read Prisma schema at "${schemaPath}"`,
          diagnostics: [
            {
              code: 'PSL_SCHEMA_READ_FAILED',
              message,
              sourceId: schemaPath,
            },
          ],
          meta: { schemaPath, absoluteSchemaPath, cause: message },
        });
      }

      const { document, sourceFile, diagnostics: parseDiagnostics } = parse(schema);
      const { table: symbolTable, diagnostics: symbolTableDiagnostics } = buildSymbolTable({
        document,
        sourceFile,
        pslBlockDescriptors: context.authoringContributions.pslBlockDescriptors,
      });

      // Do not short-circuit on provider-level diagnostics; recovered CST can
      // still produce interpreter diagnostics in the same response.
      const seedDiagnostics = [

View on GitHub (pinned to 1243cdffbe)

Solutions

  1. Verify the schema path exists on disk: `ls -la <schemaPath>` from the project root the CLI runs in.
  2. Correct the path in prisma-next.config.ts (or the source input) to point at the actual schema file.
  3. Check read permissions / container mount if the file exists but is unreadable.
  4. Use an absolute path or ensure the CLI's working directory matches the config's relative-path base.

Example fix

// before (prisma-next.config.ts)
export default defineConfig({
  contract: { sources: [{ format: 'psl', inputs: ['./prisma/schema.prisma'] }] },
});
// actual file lives at ./src/contract/schema.prisma -> ENOENT

// after
export default defineConfig({
  contract: { sources: [{ format: 'psl', inputs: ['./src/contract/schema.prisma'] }] },
});
Defensive patterns

Strategy: validation

Validate before calling

import { access, constants } from 'node:fs/promises';
async function assertSchemaReadable(schemaPath: string): Promise<void> {
  try {
    await access(schemaPath, constants.R_OK);
  } catch {
    throw new Error(`Prisma schema not readable at "${schemaPath}". Verify the path in prisma-next.config.ts inputs and file permissions before invoking prismaContract().`);
  }
}

Type guard

const isPslSchemaReadFailed = (d: ContractSourceDiagnostic): d is ContractSourceDiagnostic & { code: 'PSL_SCHEMA_READ_FAILED' } => d.code === 'PSL_SCHEMA_READ_FAILED';

Try / catch

let result;
try {
  result = await provider.load(ctx);
} catch (e) {
  throw new Error(`Unexpected error reading schema: ${String(e)}`);
}
if (!result.ok) {
  const readFail = result.diagnostics.filter(isPslSchemaReadFailed);
  if (readFail.length) {
    const meta = (readFail[0] as any)?.meta;
    throw new Error(`Cannot read schema at ${meta?.absoluteSchemaPath ?? meta?.schemaPath ?? '<unknown>'}: ${readFail[0]!.message}`);
  }
}

Prevention

When it happens

Trigger: The first resolved input in context.resolvedInputs points at a path that does not exist, is not readable by the process, or is a directory. The provider at provider.ts:104-118 catches the readFile rejection and returns notOk with this code.

Common situations: A typo or stale relative path in prisma-next.config.ts (e.g. `./prisma/schema.prisma` after moving the file). CI running from a different working directory so the relative path no longer resolves. Filesystem permissions / container read-only mounts. A path that resolves to a directory rather than a file.

Related errors


AI-assisted analysis of prisma/prisma@1243cdffbe (2026-08-01). Data as JSON: /data/errors/3dd45fd96321cca8.json. Report an issue: GitHub.